• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
60%
SHARE
TWEET

# Zeller's Algorithm (no error checking) - Python

Neec0 Jul 12th, 2013 11 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
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])
RAW Paste Data
Top