Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Zeller's Algorithm (no error checking) - Python

By: Neec0 on Jul 12th, 2013  |  syntax: Python  |  size: 0.79 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # MIT OCW 6.189
  2. # Zeller's Algorithm
  3. # July 12, 2013
  4. # This program will determine the day of the week of any given date,
  5. # past, present or future.
  6.  
  7. f_name = raw_input(str("What is your first name? "))
  8. print "Enter your date of birth"
  9. month, day, year = int(input("Month (1-12) :")), int(input("Day :")), int(raw_input("Year :"))
  10. if month <= 2:
  11.     a, new_year = month + 10, year -1
  12. else:
  13.     a, new_year = month - 2, year
  14.  
  15. b, c, d = day, new_year % 100, new_year / 100
  16. #print "a = %s, b = %s, c = %s, d = %s, new_year = %s" % (a, b, c, d, new_year)
  17. w, x, y = (13*a -1) / 5, c/4, d/4,
  18. z = w+x+y+b+c-2*d
  19. R = z%7
  20. weekdays = ("Sunday", "Monday", "Tuesday", "Wednesday",
  21.             "Thursday", "Friday", "Saturday")
  22.  
  23. print "The date %s/%s/%s falls on a %s" % (month, day, year, weekdays[R])