
Cuko T.
asked 12/24/20Can someone convert this c++ code to python?
1 Expert Answer

Patrick B. answered 12/24/20
Math and computer tutor/teacher
import math
for i in range(1,4):
i_velo = input('Please Input the Initial Velocity in meters per second :>')
weight = input(' Please input the weight :>')
angle = input(' Please input the angle :>')
f_time = 2 * float(i_velo)/(9.8*float(weight))
hmax = float(i_velo)*math.cos(float(angle)*math.pi/180)*float(f_time)
print('Max height is '+str(hmax) + 'meters')
range = (float(i_velo)*float(i_velo)*math.sin(2*float(angle)))/((float(weight)*9.8)/2)
if (range<0):
range = -range
print('range is ' + str(range) + 'meters')
time_peak = float(f_time)/2
print('Time to peak:'+str(time_peak) + ' seconds ')
Cuko T.
thank you so much. you re great.12/24/20
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
source code uploaded to RESROUCES section... I notice you are not changing the angle to radians in the sine function call12/24/20