Your Name: Hajra Chughtai
Program Name: Hajra-Homework3A.py
What the program does: This program tests if a date is a Magic Date or not.
Function to check if a date is a Magic Date
def is_magic_date(day, month, year):
return day * month == int(str(year)[-2:])
Input from the user
day = int(input("Enter the day (1-31): "))
month = int(input("Enter the month (1-12): "))
year = int(input("Enter the year (4-digit): "))
Check if the entered date is a Magic Date
if is_magic_date(day, month, year):
print(f"{day}/{month}/{year} is a Magic Date!")
else:
print(f"{day}/{month}/{year} is not a Magic Date.")
input('Press Enter to exit')
Your Name: Hajra Chughtai
Program Name: Hajra-Homework3A.py
What the program does: This program tests if a date is a Magic Date or not.
Function to check if a date is a Magic Date
def is_magic_date(day, month, year):
return day * month == int(str(year)[-2:])
Input from the user
day = int(input("Enter the day (1-31): "))
month = int(input("Enter the month (1-12): "))
year = int(input("Enter the year (4-digit): "))
Check if the entered date is a Magic Date
if is_magic_date(day, month, year):
print(f"{day}/{month}/{year} is a Magic Date!")
else:
print(f"{day}/{month}/{year} is not a Magic Date.")
input('Press Enter to exit')