request Description
In this request you will write and submit the lab1.py program. Complete and submit the file by
the deadline to receive full credit.
Before you Begin
Carefully read the “Coding Standards and Guidelines” shown on the last page of this request.
Your Python programs should follow these standards and guidelines this semester.
Problem Description
The NASA training academy wants you to expand your tennis ball movement program to determine the distance a tennis ball falls within Earth’s gravity over time. Given an initial vertical velocity of a tennis ball (meters/second), and a specified time interval (seconds), they want to calculate the position and velocity of a tennis ball at each second of the interval. You can assume the horizontal velocity is zero, since the ball is only moving vertically, and that it does not hit the ground or any obstacles. We also assume the acceleration in the vertical direction is fixed at 9.81 m/s2 due to falling within Earth’s gravity. The ball’s initial velocity may be either positive or negative (ie: falling or rising).
Using the Python IDLE editor, write a program that prompts the user for 2 values:
- the initial vertical velocity of the tennis ball
- the time at which the position of the ball is required
Using the values entered by the user, calculate and display the position, and vertical velocity of the ball at each second within the user specified time interval.
Steps for This request
- Setup your Python file lab1.py with an appropriate comments header
- Organize lab1.py using comments for each block of planned code
- In each block, write the necessary Python code to complete the task
- Save, test, then upload your completed lab1.py Python program to Blackboard
TO DO #1: Setup Your Python Program File lab1.py
In Python, the # sign indicates a comment, which documents and organizes your code. Python does not
execute these commented lines; they are used to make the program easier to understand. In the Python IDLE editor, open a new program window.
TO DO #2: Organize lab1.py using comments
There are several parts to this program. Below your program header, enter additional comments in your Python program identifying each part. Make sure to leave blank spaces between each comment section.
TO DO #3: Complete the Code
Write appropriate Python code in each section to complete the program by entering commands within the
corresponding comment blocks. You will need the following formulas to determine the position of a moving
object given an initial velocity, the acceleration of gravity and time:1
2
3
4
5
6
7
8d = (Vi * t) + 1/2 * a * T^2
Vt = Vi + a * T
Where:
• 𝑑 = current position (distance traveled)
• 𝑣% = initial velocity
• 𝑡 = the current time
• 𝑣- = velocity at the current time
• 𝑎 = acceleration of gravity
NOTE: Use the round() function to display calculated results with 2 decimal places: round(d, 2)
TO DO #4: Save and Submit your Completed Python File on Blackboard
Save your Python program using the file name lab1.py, and submit it before the deadline for full credit.
- Click the Lab 1 request on Blackboard
- Click the “Attach File” button
- Attach your lab1.py Python file
- Click submit to complete this request
Source code
1 | # |