Intro to Computer Science
PA01
Writing some simple programs
Code due to the Program Submission System on by 2/10 at 11:59pm.
Code can be submitted up to 2 days late with an automatic 10% deduction per day.
Introduction
Your book spends a lot of time talking about problem solving. Let's
look at how this would work, at least for some small problems.
Notes and requirements:
- Make sure that you save your programs in the correctly named files
- Make sure that you are following the
proper policies
regarding code based homework
- Use meaningful variable names
- Your programs should ask for input in the exact order specified in the customer requests below.
- Be sure to check you are getting full points from the autolab. If you aren't, click on your score for more info.
Program 1.1 (out of 5 points)
Create a program named discountPrice.py
- Get user input for original price and percent reduction and report the sale price for the item.
- For example, if the original price was $19.99 and the percent reduction was 30% off, then the sale price should be $13.99.
- Here is an example of exactly how your program should look:
- Hint: You will want to use the round function to round cents to 2 decimal places. For example,
amount = round(amount,2)
rounds the variable amount to two decimal places and assigns the new, nicer number back into the variable named amount.
Program 1.2 (out of 8 points)
Create a program named minutes.py
- Accept a number of minutes and indicate the equivalent number of hours and minutes.
- Hint: You will want to use // interger division and % remainder to help you.
- Here is an example:
Program 1.3 (out of 12 points)
Create a program called fuelSavings.py
- I want to know how much I would save on fuel if I bought something more fuel efficient, e.g., a hybrid car. I think the numbers I need are miles driven per year, MPG in my current car, MPG of the new car, and the cost of gasoline. Report the fuel cost for each car and the savings (or loss--a negative number) with the new/hybrid car.
- Here is an example:
Final Submission
Please submit all three programs to the Program Submission System by the due date and time.