10.8 LAB: Toll calculation Toll roads often have different fees based on the time of day and whether it's during the week or on the weekend. Write a function calc_toll() that takes three parameters:
The current hour of the day (int) Whether the time is morning (boolean) where AM = True and PM = False Whether the day is during the weekend (boolean) The function returns the correct toll fee (float), based on the chart below.
Weekday Tolls
Before 7:00 am ($1.15) 7:00 am to 9:59 am ($2.95) 10:00 am to 2:59 pm ($1.90) 3:00 pm to 7:59 pm ($3.95) Starting 8:00 pm ($1.40) Weekend Tolls
Before 7:00 am ($1.05) 7:00 am to 7:59 pm ($2.15) Starting 8:00 pm ($1.10) Example: The function calls below, with the given arguments, will return the following toll fees:
calc_toll(8, True, False) returns 2.95 calc_toll(1, False, False) returns 1.90 calc_toll(3, False, True) returns 2.15 calc_toll(5, True, True) returns 1.05
*Currenlty at 2/10, if anyone has or is able to reach solution would be helpful.
source https://stackoverflow.com/questions/75893045/python-introduction-class-10-8-lab-toll-calculation
Comments
Post a Comment