2.3 Practice

  1. Many companies pay time-and-a-half for any hours worked above 40 in a given week. Write a program to input the number of hours worked and the hourly rate and calculate the total wages for the week.  Save as 2_3_1.py

  1. A certain CS professor gives 5-point quizzes that are graded on the scale 5-A, 4-B, 3-C, 2-D, 1-F, 0-F. Write a program that accepts a quiz score as an input and uses a decision structure to calculate the corresponding grade.  Save as 2_3_2.py

  1. A certain CS professor gives 100-point exams that are graded on the scale 90–100:A, 80–89:B, 70–79:C, 60–69:D, 50-59:E: < 50: F. Write a program that ac- cepts an exam score as input and uses a decision structure to calculate the corresponding grade. Save as 2_3_3.py

  1. The body mass index (BMI) is calculated as a person’s weight (in pounds) times 720, divided by the square of the person’s height (in inches). A BMI in the range 19–25, inclusive, is considered healthy. Write a program that calculates a person’s BMI and prints a message telling whether they are above, within, or below the healthy range.  Save as 2_3_4.py

  1. The speeding ticket fine policy in Podunksville is $50 plus $5 for each mph over the limit plus a penalty of $200 for any speed over 90 mph. Write a program that accepts a speed limit and a clocked speed and either prints a message indicating the speed was legal or prints the amount of the fine, if the speed is illegal. Save as 2_3_5.py.

  1. A babysitter charges $2.50 an hour until 9:00 PM when the rate drops to $1.75 an hour (the children are in bed). Write a program that accepts a starting time and ending time in hours and minutes and calculates the total babysitting bill. You may assume that the starting and ending times are in a single 24 hour period. Partial hours should be appropriately prorated.  Save as 2_3_6.py.

  1. A person is eligible to be a US senator if they are at least 30 years old and have been a US citizen for at least 9 years. To be a US representative these numbers are 25 and 7, respectively. Write a program that accepts a person's age and years of citizenship as input and outputs their eligibility for the Senate and House.  Save as 2_3_7.py.

  1. A year is a leap year if it is divisible by 4, unless it is a century year that is not divisible by 400. (1800 and 1900 are not leap years while 1600 and2000 are.) Write a program that calculates whether a year is a leap year.   Save as 2_3_8.py.