Assignment 7 — multi-input problem solving
Due time: Wednesday, January 30
Downloads
Program all_consuming.py
- Develop a program that estimates your annual consumption of a commodity based on how much you consume each weekday and each weekend day.
Assumptions
- A week has 5 weekdays and 2 weekend days.
- A year has 52 weeks (yes, we know a real year is longer, but we will ignore that in this program).
- User supplied numbers are integers.
Requirements
- The program first prompts the user for the commodity consumed.
- The program then prompts the user for two integer inputs: first, the quantity consumed on a typical weekday, then the quantity consumed on a typical weekend day. These should be requested using two separate prompts.
- The program uses the inputs to compute and report the quantity consumed in a year.
- The second two prompts and the final report should include the commodity as listed by the user in response to the first prompt. I suggest defining two prompt variables that both make use of the supplied commondity (see notes below)
- Do not perform arithmetic inside a
print()
statement
Notes
- You cannot use the comma operator (
,
) for concatenation (string building). If you want to build a string up, use the plus operator (+
).
- After getting the commodity it might prove helpful to then set string variables (e.g.,
weekday_prompt
andweekend_prompt
orprompt1
andprompt2
or ... ) as the prompt strings for getting numeric inputs. And then use those string variables as arguments to theinput()
invocations.
- End each prompt with a space; e.g.,
input( 'What is something you consume daily?: ' )
notinput( 'What is something you consume daily?:' )
.
Suggested agorithm
- Get input commodity of interest
- Determine weekday consumption prompt
- Determine weekend day consumption prompt
- Separately get weekday and weekend day consumptions
- Compute weekly consumption
- Compute yearly consumption
- Report yearly consumption
Two program runs
What is something you consume daily? slices of cheese
Enter slices of cheese consumed on a normal weekday: 4
Enter slices of cheese consumed on a normal weekend day: 12
You consume 2288 slices of cheese per year.
What is something you consume daily? paper napkins
Enter paper napkins consumed on a normal weekday: 6
Enter paper napkins consumed on a normal weekend day: 0
You consume 1560 paper napkins per year.