Kinetic Energy
In physics, an object that is in motion is said to have kinetic energy (KE). The following formula can be used to determine a moving object’s kinetic energy:
The variables in the formula are as follows: KE is the kinetic energy in joules, m is the object’s mass in kilograms, and v is the object’s velocity in meters per second.
Write a function named kinetic_energy that accepts an object’s mass in kilograms and velocity in meters per second as arguments. The function should return the amount of
kinetic energy that the object has. Write a program that asks the user to enter values for mass and velocity, and then calls the kinetic_energy function to get the object’s kinetic
energy.
Kinetic Energy Program Code:
#The function named kinetic_energy that accepts
#an object’s mass in kilograms and velocity
#in meters per second as arguments. The function
#should return the amount of kinetic energy.
def kinetic_energy(mass, velocity):
energy = 0.5 * mass * (velocity ** 2)
return energy
# Asks the user to enter values for mass and velocity,
#and then calls the kinetic_energy function to get
#the object’s kinetic energy.
mass = float(input("Enter the mass of in kilograms: "))
velocity = float(input("Enter the velocity in meters per second: "))
# Calculating kinetic energy
energy = kinetic_energy(mass, velocity)
# Displaying the result
print("The kinetic energy", energy, "joules")
Executed Output:
Enter the mass of in kilograms: 500
Enter the velocity in meters per second: 10.5
The kinetic energy 27562.5 joules