Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Basketball Shot Simulator | Kinematics and Motion
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Physics Students

bookChallenge: Basketball Shot Simulator

To deepen your understanding of projectile motion, you will now simulate a basketball shot and determine if it successfully passes through a hoop at a specified location. This challenge uses the equations of projectile motion to model the path of the basketball, considering its initial speed and launch angle. By applying these principles, you will write a Python function to predict whether the shot results in a score, based on the ball's trajectory and the hoop's position.

Uppgift

Swipe to start coding

Write a function basketball_shot_scores(...) that determines whether a basketball shot is successful based on a simplified projectile motion model.

The function receives:

  • initial_speed — the launch speed of the ball in meters per second
  • launch_angle_deg — the launch angle in degrees
  • hoop_x, hoop_y — the horizontal and vertical position of the hoop
  • hoop_radius — optional reminder radius, default 0.23 meters

What you must do

  • Assume the ball is launched from point (0, 0).

  • Model the ball’s motion using standard projectile motion equations under gravity (g = 9.81 m/s²).

  • Determine whether the shot is successful by checking horizontal reach only:

    • Compute the horizontal range of the shot.
    • The shot is considered successful if the ball reaches the hoop’s x-position (within a tolerance based on hoop_radius).
  • Return:

    • True if the ball can reach the hoop horizontally.
    • False otherwise.

Important clarifications

  • You do not need to simulate the full trajectory step-by-step.
  • You do not need to check the ball’s exact height at the hoop (hoop_y is provided for completeness but does not affect the result).
  • The function must always return a boolean value.

Output

Return a single boolean value indicating whether the shot scores.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 5
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

bookChallenge: Basketball Shot Simulator

Svep för att visa menyn

To deepen your understanding of projectile motion, you will now simulate a basketball shot and determine if it successfully passes through a hoop at a specified location. This challenge uses the equations of projectile motion to model the path of the basketball, considering its initial speed and launch angle. By applying these principles, you will write a Python function to predict whether the shot results in a score, based on the ball's trajectory and the hoop's position.

Uppgift

Swipe to start coding

Write a function basketball_shot_scores(...) that determines whether a basketball shot is successful based on a simplified projectile motion model.

The function receives:

  • initial_speed — the launch speed of the ball in meters per second
  • launch_angle_deg — the launch angle in degrees
  • hoop_x, hoop_y — the horizontal and vertical position of the hoop
  • hoop_radius — optional reminder radius, default 0.23 meters

What you must do

  • Assume the ball is launched from point (0, 0).

  • Model the ball’s motion using standard projectile motion equations under gravity (g = 9.81 m/s²).

  • Determine whether the shot is successful by checking horizontal reach only:

    • Compute the horizontal range of the shot.
    • The shot is considered successful if the ball reaches the hoop’s x-position (within a tolerance based on hoop_radius).
  • Return:

    • True if the ball can reach the hoop horizontally.
    • False otherwise.

Important clarifications

  • You do not need to simulate the full trajectory step-by-step.
  • You do not need to check the ball’s exact height at the hoop (hoop_y is provided for completeness but does not affect the result).
  • The function must always return a boolean value.

Output

Return a single boolean value indicating whether the shot scores.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 5
single

single

some-alt