from math import pi, tan, cos # assuming that velocity given in km/h (must be converted # to m/s) and angle given in degrees (must be converted # to radians) x = 0.5 # horizontal coordinate g = 9.81 # acceleration of gravity, assume units in SI v0 = 15 # initial velocity angle = 60 y0 = 1 # initial height v02 = v0*(1000.0/3600) angle2 = angle*pi/180 y = x*tan(angle2) - 1/(2*v02**2)*g*x**2/((cos(angle2))**2) + y0 print """\ When at horizontal coordinate\n x={x:g} m, a ball with initial\n velocity v0={v0:g} km/h at {angle:g}\n degrees above the horizontal and\n initial height y0={y0:g} m is\n located at height {y:g} m. """.format(x=x, v0=v0, angle=angle, y0=y0, y=y)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question