Graded Problem Set #2.2
Conditionals
Background
These problems should be completed on your own. Unlike the practice problems, where you are allowed, and even encouraged, to talk about the process with your classmates, these should be attempted on your own. If you have difficulty with these, please reach out to me for assistance or guidance.
These problems will be completed using an editor such as Thonny or IDLE and submitted to Autolab for grading.
Activities
Please try to make your program output look as much like the example as possible and verify it works with the example input provided. If you have difficulty finding the information or understanding how to approach the problem, you should contact me.
To complete this activity, you will need to create the following scripts:
- Cond G1 - Crazy Al's Bargain Barn
- Cond G2 - How Cloudy is it?
- Cond G3 - Can I retire?
- Cond G4 - Is it a leap year?
Cond G1
Bargain. Bargain. Who wants a bargain?
Crazy Als Bargain Barn sells bangles and baubles for cheap. Everything is normally 99 cents each . However, if you buy more than 25 things he sells them to you for 94 cents each.
Write a Python script that conforms to the following
- Inputs
- asks for the number of items you are purchasing
- Print Statements
-
The cost of the items (rounded to 2 decimal places
- Example(s)
Cond G2
How Cloudy is it?
Stormy Whether is the meteoroligist at the local TV station. [Sure, you laugh at that made up name, but do you think the local CBS guy's REAL name is Joe WINTERS?]
Write a Python script that conforms to the following
- Inputs
- asks for the percentage of clouds
- Print Statements
-
The category based on the following table:
-
Percentage Description Up to and including 30% Clear Up to and including 70% Partly cloudy Up to and including 97% Cloudy Above 97% Overcast
-
- Example(s)
- NOTE:
- Remember that Python is case sensitive and Autolab will be looking for the Descriptions assigned above. This may seem like a hassle. But it is important.
Cond G3
Can I retire yet?
Ike Witt is tired of teaching. He wants to know if he can afford to retire. To draw IPERS (Iowa Public Employees Retirement System) retirement one must meet at least one of three conditions:
- age is 65 or more.
- age is at least 62 and years of service is at least 20
- sum of age and years of service equals or exceeds 88
Write a Python script that conforms to the following
- Inputs
- asks for your age
- asks for number of years you have been working for IPERS
- Print Statements
- Yes or No
- Example(s)
Cond G4
Is it a Leap Year?
Dr. Cal Lender was just reading up about leap years and he was amazed to find that everything he ever thought about leap year was WRONG. It doesn't actually automatically happen EVERY 4 years.
In fact:
- (1) There is a leap year every year whose number is perfectly divisible by four - except
- (2) for years which are both divisible by 100 and not divisible by 400.
- Rule 2 affects certain century years. For example,
- 1900 is evenly divisble by 4 and not divisible by 400. Rule 2 makes it not a leap year
- 2000 is evenly divisible by both 4 and 400. Rule 2 makes it a leap year.
Write a Python script that conforms to the following
- Inputs
- The year
- Print Statements
- Leap Year
- NOT Leap Year
- Example(s)