SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Value Returning Functions And Modules
Exercise:
Programming Exercises
Question:5 | ISBN:9780132576376 | Edition: 2

Question

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:

KE=1/2mv^{^{2}}

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.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

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

 

0 0

Discussions

Post the discussion to improve the above solution.