QUESTION IMAGE
Question
day identifier
by codechum admin
write a program that takes an integer (1 - 7) as input and prints the corresponding day of the week based on the following conditions:
- if the input is 1, print \monday\
- if the input is 2, print \tuesday\
- if the input is 3, print \wednesday\
- if the input is 4, print \thursday\
- if the input is 5, print \friday\
- if the input is 6, print \saturday\
- if the input is 7, print \sunday\
- if the input is any other value, print \invalid input\
sample output 1
enter day: 1
monday
sample output 2
enter day: 4
thursday
sample output 3
enter day: 5
friday
Step1: Get user input
day = int(input("Enter day: "))
Step2: Check conditions
if day == 1:
print("Monday")
elif day == 2:
print("Tuesday")
elif day == 3:
print("Wednesday")
elif day == 4:
print("Thursday")
elif day == 5:
print("Friday")
elif day == 6:
print("Saturday")
elif day == 7:
print("Sunday")
else:
print("Invalid input")Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
The complete Python code is as follows:
day = int(input("Enter day: "))
if day == 1:
print("Monday")
elif day == 2:
print("Tuesday")
elif day == 3:
print("Wednesday")
elif day == 4:
print("Thursday")
elif day == 5:
print("Friday")
elif day == 6:
print("Saturday")
elif day == 7:
print("Sunday")
else:
print("Invalid input")