- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to calculate acceleration, final velocity, initial velocity and time
Acceleration, final velocity, initial velocity and time are the terms related to physical science which are widely used to study the motion and mechanics. Let’s see each one in detail.
Acceleration
Acceleration is the rate at which an object changes its velocity over the given time. It is denoted by a. Mathematically it is defined as the change in velocity divided by the change in time, the following is the formula. The unit of acceleration is meters per second $\mathrm{(m/s^2)}$
$\mathrm{a \:=\:(\Delta;\:vf − \Delta;vi)/\Delta;t}$
Where,
$\mathrm{\Delta\:vi}$ is the Initial velocity
$\mathrm{\Delta\:vf}$ is the Final velocity
$\mathrm{\Delta\:t}$ is the change of time
a is the acceleration
We can calculate the acceleration for the given velocity and time by framing the formula in the code.
Example
In this example we created the acceleration function and passing the final velocity, initial velocity and time along with defining the acceleration formula then acceleration will be calculated.
vi = 45 vf = 87 t = 45 def acceleration(vi,vf,t): a = (vf - vi)/t print("Acceleration:",a) acceleration(vi,vf,t)
Output
Acceleration: 0.9333333333333333
Final velocity
Final velocity is the velocity of an object at the end of a particular time period. It is denoted by the symbol vf and is typically measured in meters per second (m/s). We can mathematically calculate the final velocity by using the below formula.
$ \mathrm{vf \:=\: a * t \:+\: vi}$
Where,
vf is the final acceleration
vi is the initial acceleration
a is the acceleration
t is the time
By using python, we can calculate the final velocity by framing the mathematical formula in the code.
Example
Here in this example we are defining the formula for final velocity in the code along with the dynamic inputs of initial velocity, acceleration and time then the it returns the final velocity.
vi = 45 a = 8 t = 98 def final_velocity(vi,a,t): vf = a * t + vi print("Final velocity:",vf) final_velocity(vi,a,t)
Output
Final velocity: 829
Initial velocity
Initial velocity is the velocity of an object at the beginning of a particular time period. It is denoted by the symbol vi and is typically measured in meters per second (m/s). Mathematical formula to calculate the initial velocity is as follows.
$\mathrm{vi\: =\: vf\: −\: a * t}$
The Initial velocity can be calculated using python by framing and using the mathematical formula in the python code.
Example
If we want to calculate the initial velocity for the given acceleration, time and final velocity then we have to use the mathematical formula in the python code.
vf = 79 a = 23 t = 35 def Initial_velocity(vi,a,t): vi = a * t - vf print("Initial velocity:",vi) Initial_velocity(vf,a,t)
Output
Initial velocity: 726
Time
Time is the duration for which an object is in motion. It is denoted by the symbol t and is typically measured in seconds (s). Mathematical formula for calculating the time is given below.
$\mathrm{t\:=\: (vf − vi)\:/\: a}$
Example
Here we are creating the python code to calculate the time with the defined final velocity, acceleration and initial velocity.
vf = 45 a = 3 vi = 56 def time(vi,a,vf): t = (vf - vi) / a print("Time:",t) time(vi,a,vf)
Output
Time: -3.6666666666666665