Last active
April 9, 2020 16:43
-
-
Save roman-on/6bb97ba4599791432d9e0a5decca5849 to your computer and use it in GitHub Desktop.
Calendar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Write a program that gets the user a date in dd / mm / yyyy format and prints the day of the week for the entered date. | |
dd/mm/yyyy | |
calendar , weekday | |
""" | |
import calendar | |
cale = input("Enter a date dd/mm/yyyy:") | |
# 15/05/2016 | |
a = cale.replace("/", "") | |
# >>> 15052016 | |
ye = int(a[-4:]) | |
mon = int(a[-6:-4]) | |
da = int(a[:-6]) | |
day_num = calendar.weekday(ye, mon, da) | |
if day_num == 0: | |
print("Monday") | |
elif day_num == 1: | |
print("Tuesday") | |
elif day_num == 2: | |
print("Wednesday") | |
elif day_num == 3: | |
print("Thursday") | |
elif day_num == 4: | |
print("Friday") | |
elif day_num == 5: | |
print("Saturday") | |
else: | |
print("Sunday") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment