Question: Python help (Getting error in pic above and also below is code in bold....) import numpy as np import matplotlib.pyplot as plt def time_to_hit_ground(y0, v0,

Python help

Python help (Getting error in pic above and also below is code

(Getting error in pic above and also below is code in bold....)

import numpy as np

import matplotlib.pyplot as plt

def time_to_hit_ground(y0, v0, a):

discriminant = np.sqrt(v0**2 - 2*a*y0)

t1 = (-v0 - discriminant) / a

t2 = (-v0 + discriminant) / a

if t1 >=0:

return t1

return t2

def drop(y0, v0=0.0, dt=0.1, g=-9.8):

if y0

print('Object is underground.')

return

# if you also allow the user to change `dt` and `g` from the arguments,

t_ground = time_to_hit_ground(y0, v0, g)

t = np.arange(0, t_ground+dt, dt)

v = v0 + g * t

y = y0 + v0 * t + g * t**2 / 2.

plt.plot(t, y, '.')

plt.axvline(t_ground, color='g')

plt.axhline(0, color='g')

plt.xlabel('Time (s)')

plt.ylabel('Height (m)')

plt.title('ANVIL')

plt.show()

t1= (-vo - discriminant ) / a t2 = (-70 + discriminant ) / a if t1 >=0: SyntaxError return tl return t2 return' outside function def drop (yo, v0=0 . 0, dt-0 . 1, g=-9.8): if yo

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!