This Python program calculates the acceleration of a cyclist who starts at an initial speed x (in km/h) and reaches a final speed k (in km/h) after n minutes.
To compute acceleration, we first convert speeds to meters per second and time to seconds.
The formula used is:
acceleration = (final_speed - initial_speed) / time
# Get inputs from user
x_kmh = float(input("Enter initial speed (km/h): "))
k_kmh = float(input("Enter final speed (km/h): "))
n_minutes = float(input("Enter time duration (minutes): "))
# Convert speeds to m/s and time to seconds
x_mps = x_kmh * 1000 / 3600
k_mps = k_kmh * 1000 / 3600
time_seconds = n_minutes * 60
# Calculate acceleration
acceleration = (k_mps - x_mps) / time_seconds
# Display result
print("\n--- Result ---")
print(f"Acceleration = {acceleration:.4f} m/s²")
Enter initial speed (km/h): 10
Enter final speed (km/h): 25
Enter time duration (minutes): 5
--- Result ---
Acceleration = 0.0833 m/s²
- Speeds are converted from km/h to m/s using × 1000 / 3600
- Time is converted from minutes to seconds using × 60
- Acceleration is calculated as change in speed divided by time
- The result is shown with four decimal places for precision