| 8 | |
| 9 | # Complete the libraryFine function below. |
| 10 | def libraryFine(d1, m1, y1, d2, m2, y2): |
| 11 | if y1<=y2: # checking whether the returned year is less than equal to the due year |
| 12 | if y1<y2: |
| 13 | fine =0 |
| 14 | else: # when both the years are equal |
| 15 | if ((m1==m2) and (d1<=d2)) or (m1<m2): # check for due month and returned month is same but the returned date is less than the due date, or due month is more than the returned month |
| 16 | fine=0 |
| 17 | else: # check for when the returned date is past the due date |
| 18 | if (d1>d2) and (m1==m2): # month is same but the returned date is more |
| 19 | fine = 15*(d1-d2) |
| 20 | else: # returned month is more than the due month |
| 21 | fine = 500*(m1-m2) |
| 22 | else: # returned year is more than the due year |
| 23 | fine=10000 |
| 24 | return fine |
| 25 | |
| 26 | |
| 27 | |