Python program to calculate acceleration, final velocity, initial velocity and time
Here we can find the acceleration (a), final velocity(v), initial velocity(u) and time(t) using the formula a = (v-u)/t.
At first, functions are defined for all four types of calculations, in which they will accept three inputs and assign the value in three different variables. Then the fourth value is calculated using the acceleration formula and the calculated value is returned. We are going to use the same acceleration formula in different approaches.
Hey! Looking for some great resources suitable for young ones? You've come to the right place. Check out our self-paced courses designed for students of grades I-XII.
Start with topics like Python, HTML, ML, and learn to make some games and apps all with the help of our expertly designed content! So students worry no more, because GeeksforGeeks School is now here!
Approach:
- In the first approach, we will find initial velocity by using the formula “u = (v-a*t)”
- In the second approach, we will find final velocity by using formula “v = u + a*t”
- In the third approach, we will find acceleration by using formula “a = (v – u)/t”
- In the fourth approach, we will find time by using formula “t = (v – v)/a”
Example 1: Initial velocity (u) is calculated.
Python3
# code# Enter final velocity in m/s:finalVelocity = 10# Enter acceleration in m per second squareacceleration = 9.8#Enter time taken in secondtime = 1initialVelocity = finalVelocity - acceleration * timeprint("Initial velocity = ", initialVelocity) |
Output:
Initial velocity = 0.1999999999999993
Example 2: Final velocity (v) is calculated.
Python3
# code# initial velocity in m/s:initialVelocity = 10# acceleration in m per second squareacceleration = 9.8# time taken in secondtime = 1finalVelocity = initialVelocity + acceleration * timeprint("Final velocity = ", finalVelocity) |
Output:
Final velocity = 19.8
Example 3: Acceleration (a) is calculated.
Python3
#code# initial velocity in m/sinitialVelocity = 0# final velocity in m/sfinalVelocity = 9.8# time in secondtime = 1acceleration = (finalVelocity - initialVelocity) / timeprint("Acceleration = ", acceleration) |
Output:
Acceleration = 9.8
Example 4: Time (t) is calculated.
Python3
# code#final velocity in m/sfinalVelocity = 10#initial velocity in m/sinitialVelocity = 0#acceleration in meter per second squareacceleration = 9.8time = (finalVelocity - initialVelocity) / accelerationprint("Time taken = ", time) |
Output:
Time taken = 1.0204081632653061

