Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. print("-------------------------------RESTART---------------------------------")
  4. day = int(input("Δώσε τον αριθμό που αντιστοιχεί στην ημέρα της ημερομηνίας: "))
  5. day = int(day)
  6. month = input("Δώσε τον αριθμό που αντιστοιχεί στο μήνα της ημερομηνίας: ")
  7. month = int(month)
  8. year = input("Δώσε τον αριθμό που αντιστοιχεί στο έτος της ημερομηνίας: ")
  9. year = int(year)
  10.  
  11. isLeapYear = (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0)
  12.  
  13. validDaysPerMonth = [0, 31, 28, 31, 30 ,31 ,30 ,31, 31, 30, 31, 30, 31] # To 0 einai padding, gia na antistixei to index ston mina
  14. if isLeapYear(year):
  15.     validDaysPerMonth[2] = 29
  16.  
  17. if month<0 or month>12 or day<0 or day>validDaysPerMonth[month]:
  18.     print("Δεν υπάρχει μέρα που να αντιστοιχεί στον αριθμό" + " " + str(day) + " " + "του μήνα " + " " + str(month) + " " + "για τον χρόνο" + " " + str(year))
  19. else :
  20.     print("Η ημερομηνία " + str(day) + "/" + str(month) + "/" + str(year) + " " + "είναι έγκυρη")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement