Advertisement
STANAANDREY

ex10 lab1 LSD

Sep 30th, 2022 (edited)
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. def leap_year(year):
  2.     return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0
  3.  
  4.  
  5. def days_diff(year1, year2):
  6.     diff = (year2 - year1) * 365
  7.  
  8.     for year in range(year1, year2):
  9.         if leap_year(year):
  10.             diff += 1
  11.  
  12.     return diff
  13.  
  14.  
  15. if __name__ == "__main__":
  16.     year1 = int(input('year1='))
  17.     year2 = int(input('year2='))
  18.     print("day diff: " + str(days_diff(year1, year2)))
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement