Intro to Computer Science
PA02
Working with Selection Statements
Code due to the Program Submission System on by 9/18 at 11:59pm
Introduction
This week we have been working with selection statements. Let's see if
you understand this idea.
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.
Program 2.1 (5 points)
Create a program named tip.py
- I always tip 20% of the meal cost. But I know that people working at inexpensive places work as hard to serve me as those in expensive places so I always tip at least $2.50. Produce code that will calculate my tip.
- Accept an input value as a float for the meal cost, and calculate and print the tip.
- Here is an example:
- Here is another example:
Program 2.2 (8 points)
Create a program named weather.py
- Produce code to accept a number indicating the percentage of the sky that has clouds and report a cloudiness descriptor, according to the following chart.
Percentage |
Description |
30 or less |
Clear |
between 31 and 70 |
Partly cloudy |
between 71 and 99 |
Cloudy |
exactly 100 |
Overcast |
- Here is an example:
- Here is another example:
- Here is another example:
- Here is another example:
Program 2.3 (12 points)
Create a program named height.py
- Normal height for US females is 64 inches plus/minus 2.5 inches and for US males it is 69.5 inches plus/minus 3 inches. Accept input values indicating gender (F or M) and height and then report whether a person with those characteristics is within the average height range.
- Hint: Is 66.5 inches in the average range or not for a female person? (It is in this case, but 66.6 is not.) Be sure you test all of these "boundary cases".
- Here is an example:
- Here is another example:
- Here is another example:
Final Submission
Please submit all three programs to the Program Submission System by the due date and time.