Need help how to fix the python program

Need help how to fix the python program
0

#1
import math
speed=30                        # meters/second  
angle=math.pi/4.0                   # in radians
XYspeed=math.sin(angle)*speed   # horizontal speed
g=9.8            #meters/second^2
print("speed is", speed *3.6,"km/h.",xyspeed,"m/s")
for tick in range(0,50):
    t=tick/10                       #in seconds
print("Time:", t , "distance:", distance=XYspeed * t ,"height:", height= XYspeed *t- g*t^2)

This program isnt running and giving me error in line 9 im quite new to python so any help would be highly appreciated. Thanks in advance.


#2

Indent the code properly. add 4 spaces before 9th line. Also correct the last line after height =
while pasting code try to paste code using the “preformatted text”.


#3

Ok so First in your 6th line change xyspeed to XYspeed because thats the variable you are using to store horizontal speed in your code.

Next 9th line print statement should be right below the place from where the 8th line starts.

Finally for height calculation you are using ^ operand to raise power. Use ** instead to raise power. Try this for the 9th line:

print(“Time:”, t , “distance:”, XYspeed * t ,“height:”, XYspeed t- gt**2)


#4

thanks for the help. And my apologies for late reply