สถานะการส่งล่าสุด: -

SOS11: Projectile

Projectile

You need to write a projectile function that return the string with 2 float inputs which are starting velocity and starting angle in degree, then calculate the time and distance of the object. given \(g=9.81\)

hint: \(\theta\) in the formula is in degree you need to change it to radian \[ t=\frac{2u\sin{\theta}}{g} \]

\[ S=ut\cos{\theta} \]

Example Outputs

Enter velocity in meter per second: 10
Enter the angle: 90
Time: 2.04 s, Total distance: 0.00 meter(s)


Enter velocity in meter per second: 0
Enter the angle: 45
Time: 0.00 s, Total distance: 0.00 meter(s)


Enter velocity in meter per second: 20
Enter the angle: 45
Time: 2.88 s, Total distance: 40.77 meter(s)


import math
# A function to calculate time and distance of projectile.
# The function takes two arguments (initial velocity , initial angle)
velocity = float(input("Enter velocity in meter per second: "))
degree = float(input("Enter the angle: "))
print(projectile(velocity, degree))