5(iii)
A library charges fine according to the number of days a book returned late, according to the following criteria.
| Days | Fine per day |
|---|---|
| First 10 days | Rs. 1 |
| Next 10 days | Rs. 2.5 |
| Beyond 20 days | Rs.5 |
Write a program to enter the number of days a book was returned late and print the fine to be paid.
Show SolutionHide Solution↓
days = int(input("Enter number of days late: "))
if days <= 10:
fine = days * 1
elif days <= 20:
fine = 10 * 1 + (days - 10) * 2.5
else:
fine = 10 * 1 + 10 * 2.5 + (days - 20) * 5
print("Fine to be paid:", fine)
Enter number of days late: 25
Fine to be paid: 60.0