KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

A library charges fine according to the number of days a book returned late, according to the following criteria.

DaysFine per day
First 10 daysRs. 1
Next 10 daysRs. 2.5
Beyond 20 daysRs.5

Write a program to enter the number of days a book was returned late and print the fine to be paid.

Python Control Flow

2 Likes

Answer

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)

Output

Enter number of days late: 25
Fine to be paid: 60.0

Answered By

3 Likes


Related Questions