fork download
  1. # Zellers.py
  2. # October 31, 2013
  3. # Glenn Richard
  4. # See http://www.timeanddate.com/calendar/
  5. # Valid for Gregorian Calendar (September 14, 1752 or later)
  6. daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  7. months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
  8. # first = input("Enter your first name: ")
  9. # last = input("Enter your last name: ")
  10. print("Enter date")
  11. month = int(input("Month (1 - 12): "))
  12. day = int(input("Day: "))
  13. year = int(input("Year: "))
  14. if month < 3:
  15. yr = year - 1
  16. else:
  17. yr = year
  18. a = (month + 9) % 12 + 1
  19. b = day
  20. c = yr % 100
  21. d = yr // 100
  22. w = (13 * a - 1) // 5
  23. x = c // 4
  24. y = d // 4
  25. z = w + x + y + b + c - 2 * d
  26.  
  27. r = z % 7
  28. dayOfWeek = daysOfWeek[r]
  29. print(months[month - 1] + " " + str(day) + ", " + str(year) + " falls on a " + dayOfWeek + ".")
Success #stdin #stdout 0.03s 9440KB
stdin
1
1
2014
stdout
Enter date
Month (1 - 12): Day: Year: January 1, 2014 falls on a Wednesday.