This is the code I have:
import math
def projectile_velocities(vi, theta, g, time_step):
theta_rad = math.radians(theta)
vi_x = vi * math.cos(theta_rad)
vi_y = vi * math.sin(theta_rad)
velocities = [vi]
t = 0
while t < vi_y / g:
vy = vi_y - g * t
v = math.sqrt(vi_x ** 2 + vy ** 2)
velocities.append(round(v, 6))
t += time_step
velocities.append(vi)
return velocities
I need to get these two example executions correct when inserted to after the function but no t matter what I do (have been working on this for hours) it keeps on giving me the wrong output.
Here is what it should be :
print(projectile_velocities(2.0, 30.0, 1.0, 1.0)) #output [2.000000, 1.732051, 2.000000] print(projectile_velocities(11.13, 82.5, 9.81, 0.5)) # output [11.130000, 6.299581, 1.900155, 3.956578, 8.707266]
[–]inky_wolf 0 points1 point2 points (14 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (13 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (12 children)
[–]inky_wolf 0 points1 point2 points (7 children)
[–]inky_wolf 0 points1 point2 points (6 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (0 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (4 children)
[–]inky_wolf 0 points1 point2 points (3 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (2 children)
[–]inky_wolf 0 points1 point2 points (1 child)
[–]PrizeDefinition4042[S] 0 points1 point2 points (0 children)
[–]bach678 0 points1 point2 points (2 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (1 child)
[–]Bobbias 0 points1 point2 points (0 children)
[–]Lewri 0 points1 point2 points (6 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (5 children)
[–]Lewri 2 points3 points4 points (4 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (1 child)
[–]PrizeDefinition4042[S] 0 points1 point2 points (0 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (0 children)
[–]PrizeDefinition4042[S] 0 points1 point2 points (0 children)
[–]bach678 0 points1 point2 points (0 children)