A library charges overdue fees for a borrowed book using the following fee schedule:
less than 4 days late: 1 dollar per day
4 to 6 days late: 2 dollars per day (for all days, including the first 3 days)
more than 6 days late: 3 dollars per day (for all days, including the first 6 days)
Borrowers of books are in one of these age groups: CHILD, ADULT, or SENIOR. A CHILD gets charged only half of the fees and a SENIOR gets charged only one quarter of the fees. An ADULT pays the full fee.
Complete the following function according to the description above and the docstring below.
def overdue_fees(days_late, age_group): """ (int, str) -> number
Return the fees for a book that is days_late days late for a borrower
in the age group age_group.
>>> overdue_fees(2, SENIOR) # 2 days late, SENIOR borrower
0.5
>>> overdue_fees(5, ADULT) # 5 days late, ADULT borrower
10
"""
fees = 0
#if days_left < 4 and age_group = CHILD
fees = (days_late * 1) / 2
#elif days_left > 4 and < 6
fees = (days_late * 2) / 2
#else days_left < 6
fees = (days_late * 3) / 2
#elif days_left < 4 and age_group = ADULT
fees = days_late * 1
#elif days_left > 4 and < 6
fees = days_late * 2
#else days_left < 6
fees = days_late * 3
#if days_left < 4 and age_group = SENIOR
fees = (days_late * 1) / 4
#elif days_left > 4 and < 6
fees = (days_late * 2) / 4
#else days_left < 6
fees = (days_late * 3) / 4
return fees
I am having a hard time figuring out why my code does not work. If someone can provide a right solution I can reverse engineer it and figure it out. Thanks
Aucun commentaire:
Enregistrer un commentaire