Www2.cs.arizona.edu
Programming Project 1: Three Programs
Collaboration: Solo! Work on these three programs by yourself.
Due: Tuesday 6-Sep by 4:00 pm (Note: After Labor Day, we will have projects due Mondays at 9:00pm. No section leaders will be in the lab on Labor Day)
Turn in: Turn in all three files in to ISTA 130 D2L drop box named 'Project 1: Three Programs'
Grading: 100 points. For specific criteria see the Grading Criteria section at the end of this file
This programming project gives you a chance to implement some Input/Process/Output algorithms as Python programs while practicing computing and a few functions like print(), input(), eval(), and round(). At the beginning of each program, include comments with the information listed here where you have filled in the correct information for the [Appropriate parts]:
# Developer: [Your name]
#
# SL: [Your SL's name here]
#
# File: [programName.py]
#
# Due: [Project Due Date and Time]
#
# Purpose: [A one-paragraph description of what the program does.]
#
The following example may be used as the beginning to the first program in a file name lightning.py (you need to change a few things):
# Developer: [firstName lastName]
#
# SL: [Your SL's name here]
#
# File: lightning.py
#
# Due Date: 4:00 pm Tuesday 6-Sep-11
#
# Purpose: This program computes the distance you were from a lightning strike
# after entering the number of seconds between the flash and the thunder.
#
# The first statement is given (no need for def main() in this project.
print('This program finds the distance to a lightning strike.')
# TODO: Complete an Input/Process/Output algorithm here:
Program 1 When it is monsoon season in Tucson the weather can be a little cooler when storms are in the area. On a cloudy day you decided to go hiking but you can see lightning in the distance and hear thunder. How many miles away is the lightning? (“How fast can you run to your car?” is a question for another assignment!).
Complete a program in the file lightning.py that calculates the distance to a lightning strike based on the time elapsed between the flash and the sound of thunder. The speed of sound is approximately 1100 ft/sec and 1 mile is 5280 ft. A sample execution of your program where the user enters 10 for seconds should look like precisely like this:
This program finds the distance to a lightning strike.
How many seconds between seeing the lightning flash and hearing the thunder? 10
For 10 seconds, lightning flashed 2.08 miles away.
Notes
• Round miles to two decimal places
Program 2 An object’s momentum is its mass (in kilograms) multiplied by its velocity (in meters per second). And a moving object’s kinetic energy (KE) is measured in Joules and is found by the formula KE =(1/2)mv2 where m is the object’s mass and v is its velocity.
Complete a program in the file energy.py that gets a name of an entity from the user as well as the object’s mass in kilograms and its velocity and then calculates and prints out the name of the object along with its momentum and kinetic energy. A sample dialog where the users enters elephant with a mass of 5000 kg and velocity of 6.9 should look precisely like this:
This program finds the momentum and kinetic energy of a moving object.
Enter a type of object: elephant
What is its mass in kilograms? 5000
What is its velocity in meters per second? 6.9
A(n) elephant with a mass of 5000 kg and a velocity of 6.9 meters/second has a momentum of 34500.0 of kg-meters/second and kinetic energy of 119025.0 Joules!
Notes
• Round the velocity and momentum to one decimal place
Program 3 The US Census webpage gives information about the current US population as well as approximate rates of change for it (and lots of other cool stuff!). Complete a program in population.py that asks the user for a year greater than 2011 and then displays the new estimated total population since 2011.
If you look at the webpage, you’ll likely see a different population change! For this program assume the current US population is 310,198,453. And use these estimated rates of change:
• A birth every 7 seconds
• A death every 13 seconds
• A new immigrant every 36 seconds
Assume that every year is exactly 365 days (no leap year for us!) and note that the rate of change units are in seconds. After getting the target year (2012 below), print the number of births, immigrants, and deaths. Follow these predictions with the total increase in population and the new estimate for the target year. Sample output from running your program twice with the given year (2011) and population (310198453) with a user's input of 2012, your dialog should look precisely like this:
Enter a year after 2011 for the estimated US population since 2011: 2012
Births: 4505143
Immigrants: 876000
Deaths: 2425846
Total increase: 2955297 since 2011
In the year 2012 the new estimated US population: 313153750
Notes
• Assume the current year is 2011 and the starting population is 310,198,453
• The number of seconds in one year = 365 * 24 * 60 * 60
• Round births, deaths, and immigrants to the nearest integer (it is an approximation)
Grading Criteria 100pts total
___ / 2 Code in lightning.py compiles and attempts to solve Program 1
___ / 2 Code in energy.py compiles and attempts to solve Program 2
___ / 2 Code in population.py compiles and attempts to solve Program 3
___ / 21 Code in lightning.py is correct. It always works for valid input (no bad input allowed)
___ / 21 Code in energy.py is correct. It always works for valid input (no bad input allowed)
___ / 21 Code in population.py is correct. It always works for valid input (no bad input allowed)
___/ 31 Style and Design
___ / 9 You commented (documented) each program as requested (3 pts each)
___/ 12 Your output is exactly as requested or close (3 pts each)
___/ 2 You rounded one output to 2 decimals in lightning.py
___/ 2 You rounded two outputs to 1 decimal in energy.py
___/ 6 You used meaningful names for all identifiers (2 pts each).
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.