Question
Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of
Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week where 1 = Monday, 2= Tuesday, etc....The program should display an error message if the user enters a number that is outside the range of 1 through 7
SOLUTION:
# Get the number for the day of the week. day = int(input('Enter a number (1-7) for the day of the week: '))
# Determine the name of the day of the week, and display it. 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 ('Error: Please enter a number in the range 1-7.')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started