You are on page 1of 3

Alvarado, Donita Rose B.

Busaing, Remedios Mae F.

BSIT603

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:

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.

Part 1. (45 points)


Using your preferred Python IDE or this online IDE, create a program with a function
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.
Ask the user to enter values for mass and velocity, and then call the function you
created to get the object’s kinetic energy.
Here is the syntax for creating a Python function:

Sample output:
Part 2.
1. Variable names used and their categories (5 points)

• kinetic_energy: float, result of kinetic energy calculation


• mass: float, user input for the object's mass
• velocity: float, user input for the object's velocity
2. Special words used (5 points)

• def, used to define the function


• return, used to return the value calculated in the function
• float, used to convert user input to floating-point numbers
• input, used to prompt the user for input

3. Scoping rule used in the function (static or dynamic) and one-sentence


explanation of why it falls under that rule (5 points)

• Python implements a dynamic scoping rule. The variables declared in the main
program (mass and velocity) are accessible to the function kinetic_energy since
they are defined in the same namespace (global scope).

You might also like