-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate_time_check.py
More file actions
24 lines (18 loc) · 821 Bytes
/
date_time_check.py
File metadata and controls
24 lines (18 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Write a function to determine if the 13th day of a given month and year falls on a Friday
Instructions
Create a date object for the 13th day of the given month and year. Then check if this date is a Friday.
Return True if the 13th day of the given month and year is a Friday, otherwise return False.
Hint: In Python's datetime module, Monday is 0 and Sunday is 6. So, Friday is 4
Example:
input: 8 2021
output :True
Reason: The 13th day of August in the year 2021 falls on a Friday
"""
import datetime
def is_friday_13(month, year):
# Create a date object for the 13th day of the given month and year
date_13th = datetime.date(year, month, 13)
# Check if the weekday of the 13th day is Friday (4)
return date_13th.weekday() == 4
# Test the function
print(is_friday_13(9, 2024)) # Output: True