Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I write my input in python programming? My output is here Enter the objec

ID: 668320 • Letter: H

Question

How do I write my input in python programming?

My output is here

Enter the object's initial position: 0
Enter the object's initial velocity: 15
Enter the object's acceleration: 3
Enter the time that has elapsed: 5

The object's final position is 112.5

Explanation / Answer

#!/usr/bin/python # This is statement is required by the build system to query build info if __name__ == '__build__': raise Exception ''' Author: Brad Hollister. Started: 02.07.2013 Code advects streamlines for each ensemble member and increments the number of times a streamline crosses a given cell. ''' import nrrd import sys, struct import math as pm import numpy as np import pylab as p import math import csv import matplotlib.pyplot as plt import h5py from netcdf_reader import * ''' TOTAL_STEPS = 25 integration_step_size = 0.1 SEED_LAT = 42 SEED_LON = 21 SEED_LEVEL = 0 ''' vclin = [] cf_vclin = [] INPUT_DATA_DIR = '/home/behollis/Dropbox/stirringData/data/' OUTPUT_DATA_DIR = '/home/behollis/Dropbox/visweek2015/oslines/' #streamline positions (forward/backward from seed point) and cell counts g_sl_f = [[],[],[]] g_sl_b = [[],[],[]] # from.. http://doswa.com/2009/01/02/fourth-order-runge-kutta-numerical-integration.html #http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_method def rk4(x, v, a, dt): """Returns final (position, velocity) tuple after time dt has passed. x: initial position (number-like object) v: initial velocity (number-like object) a: acceleration function a(x,v,dt) (must be callable) dt: timestep (number)""" x1 = x v1 = v a1 = a(x1, v1, 0) x2 = x + 0.5*v1*dt v2 = v + 0.5*a1*dt a2 = a(x2, v2, dt/2.0) x3 = x + 0.5*v2*dt v3 = v + 0.5*a2*dt a3 = a(x3, v3, dt/2.0) x4 = x + v3*dt v4 = v + a3*dt a4 = a(x4, v4, dt) xf = x + (dt/6.0)*(v1 + 2*v2 + 2*v3 + v4) vf = v + (dt/6.0)*(a1 + 2*a2 + 2*a3 + a4) return xf, vf #from http://stackoverflow.com/questions/8661537/how-to-perform-bilinear-interpolation-in-python def bilinear_interpolation(x, y, points): '''Interpolate (x,y) from values associated with four points. The four points are a list of four triplets: (x, y, value). The four points can be in any order. They should form a rectangle. >>> bilinear_interpolation(12, 5.5, ... [(10, 4, 100), ... (20, 4, 200), ... (10, 6, 150), ... (20, 6, 300)]) 165.0 ''' # See formula at: http://en.wikipedia.org/wiki/Bilinear_interpolation # points = sorted(points) # order points by x, then by y (x1, y1, q11), (_x1, y2, q12), (x2, _y1, q21), (_x2, _y2, q22) = points ''' if x1 != _x1 or x2 != _x2 or y1 != _y1 or y2 != _y2: raise ValueError('points do not form a rectangle') if not x1
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote