You will write three functions about a ball thrown from the ground. The first uses the exact formulas, the second moves the ball in small steps, and the third finds the angle that gives the longest flight distance.
The idea. The acceleration is the constant vector with . In a small time step dt, the velocity changes by acceleration * dt and the position by velocity * dt. The exact answers are time , range and height .
Your tasks.
exact(v0, angle_deg). Return the tuple (time, range, height) from the formulas.fly(v0, angle_deg, dt). Move the ball in steps of dt until it is back at height or lower. Return (time, range, height), where height is the greatest height seen.best_angle(v0). Try the whole angles from to degrees with exact, and return the angle with the greatest range.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…