request Description
In this request you will write and submit the labprep1.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.
Write a Python Program to Calculate the Position of a Tennis ball at a Time Specified
The NASA training academy wants to make use of your superior programming skills to help teach students about the way objects move in a zero gravity environment. They want to simulate the position a tennis ball at a specified time, given an initial velocity. We will assume the acceleration in the horizontal direction is zero, so the velocity will not change over time.
Using the Python IDLE editor, write a program that prompts the user for 2 values:
- the initial speed (velocity) of the tennis ball
- the travel time of the ball in space
Using the values entered by the user, calculate and display the distance the ball has traveled.
Steps For This request:
- Setup your Python file labprep1.py with an appropriate comments header
- Organize labprep1.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 labprep1.py Python program to Blackboard
TO DO #1: Setup Your Python Program File labrep1.py
In Python, the # sign indicates a comment, which documents and organizes your code. Python does not execute these commented lines; they help make the program easier to understand.
In the Python IDLE editor, open a new program window. At the top of the file, create a program header by typing in the following text:
1 | # |
TO DO #2: Organize labrep1.py using comments
There are 4 parts to this program:
- Display the description of the program
- Prompt the user for input values
- Calculate the distance traveled by the tennis ball over the time specified
- Display the results
Below your program header, enter the following comments (pseudocode) in your Python program identifying each part. Leave blank spaces between each comment.1
2
3
4
5
6# Display a message describing the functionality of the program
# Prompt the user for the initial velocity of the ball
# Prompt the user for the time in seconds
# Calculate the distance traveled using the formula:
# distance = velocity * time
# Display the results of the calculation
TO DO #3: Complete the Code
Write appropriate Python code in each section to complete the program by entering commands under the corresponding comment blocks.
Example Input / Output
Your Python program should display a number grid that is organized and easy to read. Below are some example results you can use to test your program. You will only display one result each time you run your program.
TO DO #4: Save and Submit your Completed Python File on Blackboard
Save your Python program using the file name labprep1.py, and submit it before the deadline for full
credit.
- Click the Lab Prep 1 request on Blackboard
- Click the “Attach File” button
- Attach your labprep1.py file
- Click submit to complete this request
Source code
1 | # |