Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://lifehacker.ru/kakoj-den-nedeli
- day = int(input("День: "))
- month = int(input("Месяц: "))
- year = int(input("Год: "))
- def is_year_leap(year_num):
- return (year_num % 4 == 0 and year_num % 100 != 0) or (year_num % 400 == 0)
- def get_month_code(month_num, year_num):
- if month_num == 1:
- if is_year_leap(year_num):
- return 0
- else:
- return 1
- elif month_num == 2:
- if is_year_leap(year_num):
- return 3
- else:
- return 4
- elif month_num == 3:
- return 4
- elif month_num == 4:
- return 0
- elif month_num == 5:
- return 2
- elif month_num == 6:
- return 5
- elif month_num == 7:
- return 0
- elif month_num == 8:
- return 3
- elif month_num == 9:
- return 6
- elif month_num == 10:
- return 1
- elif month_num == 11:
- return 4
- elif month_num == 12:
- return 6
- def get_century_code(year_num):
- n = year_num // 100 % 4
- if n == 0:
- return 6
- elif n == 1:
- return 4
- elif n == 2:
- return 2
- elif n == 3:
- return 0
- def get_year_code(year_num):
- return (get_century_code(year_num) + year_num % 100 + year_num % 100 // 4) % 7
- result = (day + get_month_code(month, year) + get_year_code(year)) % 7
- if result == 2:
- print("Понедельник")
- elif result == 3:
- print("Вторник")
- elif result == 4:
- print("Среда")
- elif result == 5:
- print("Четверг")
- elif result == 6:
- print("Пятница")
- elif result == 0:
- print("Суббота")
- elif result == 1:
- print("Воскресенье")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement