In: Computer Science
Chapter 6, Starting out with Programming and Logic, 4th Edition, Page 265 #6 Kinetic Energy
In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object’s kinetic energy:
KE=12mv2
The variables in the formula are as follows: KE is the kinetic energy, m is the object’s mass in kilograms, and v is the object’s velocity, in meters per second. Design a function named kineticEnergy 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. Design a program that asks the user to enter values for mass and velocity, and then calls the kineticEnergy function to get the object’s kinetic energy. PLEASE CREATE A FLOWCHART USING FLOWGORITHM. PLEASE PROVIDE SCREENSHOTS OF FLOWCHART AND TEST RUN.
Answer:
Here is the python code as per your requirment
Raw code:
def kineticEnergy(m,v):
'''
KE is the kinetic energy,
m is the object’s mass in kilograms,
v is the object’s velocity, in meters per second.
'''
KE=1/2*(m*v*v)
#returning the kinetic enerty
return KE
#main
def main():
#asking the mass and velocity to user
mass=float(input("Enter the mass(kgs): "))
velocity=float(input("Enter the velocity(mts): "))
#printing the output
print(kineticEnergy(mass,velocity))
#calling main function
main()
Raw code:
ouptut:
Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.
"Please refer to the screenshot of the code to understand the indentation of the code".
Thank you! Do upvote.