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).
Python Advanced Programming: The Guide to Learn Python Programming. Reference with Exercises and Samples About Dynamical Programming, Multithreading, Multiprocessing, Debugging, Testing and More