Python Day 26: Nested Logic




Your local library needs your help! Given the expected and actual return dates for a library book, create a program that calculates the fine (if any). The fee structure is as follows:

If the book is returned on or before the expected return date, no fine will be charged (i.e. fine=0) .
If the book is returned after the expected return day but still within the same calendar month and year as the expected return date, fine= 15 Hackos x number of days late.
If the book is returned after the expected return month but still within the same calendar year as the expected return date, the fine= 500Hackos x number of days late.
If the book is returned after the calendar year in which it was expected, there is a fixed fine of 10000 Hackos



  1. returned_date = list(map(int,input().split(' ')))
  2. expected_date = list(map(int,input().split(' ')))
  3. fine = 0
  4. if returned_date[2] > expected_date[2]:
  5. fine = 10000
  6. elif returned_date[2] == expected_date[2]:
  7. if returned_date[1] > expected_date[1]:
  8. fine = (returned_date[1] - expected_date[1])*500
  9. elif returned_date[1] == expected_date[1]:
  10. if returned_date[0] > expected_date[0]:
  11. fine = (returned_date[0] - expected_date[0])*15
  12. print(fine)




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube