10. Python Program to find Mechanical Energy of a particle is given by e=mgh+(1/2)mv^2.
How does this program work?
- In this program you will learn about how to calculate Mechanical Energy using Python.
- This program requires the user inputs Mass ,displacement and velocity of an object.
- In this program First we calculate Potential Energy and Kinetic Energy.
- After that we will be find Mechanical energy by the combination of kinetic energy and potential energy.
Here is the code
g = 9.8
m = int(input('Enter Mass of an object(Kg): '))
h = int(input('Enter displacement of an object(m): '))
v = int(input('Enter velocity of an object(m/s): '))
P = m*g*h #Potential energy(P.E = mgh)
K =0.5*m*v*v #Kinetic energy(K.E = 1/2mv^2)
M = P+K #To calculate Mechanical energy(M.E = P.E+K.E)
print("Potential Energy : " ,P,"J")
print("Kinetic Energy : " ,K,"J")
print("Total Mechanical Energy: " ,M,"J")