Respuesta :
Answer:
Explanation:
The result structure that we are to use to arrange this program needs to have the ability to differentiate paths depending on way of 8 different inputs that is given (one for every day of the week and another one incase the input is outside the range it's supposed to be in). A group of nested “if” statements should work but would be horribly complicated in looking. A much more innovative approach is to use an if - elif - else structure:
user_input = input('Enter a number: ')
if user_input == '1':
print(user_input, '= Monday')
elif user_input == '2':
print(user_input, '= Tuesday')
elif user_input == '3':
print(user_input, '= Wednesday')
elif user_input == '4':
print(user_input, '= Thursday')
elif user_input== '5':
print(user_input, '= Friday')
elif user_input== '6':
print(user_input, '=Saturday')
elif user_input == '7':
print(user_input, '=Sunday')
else:
print('Error: That number doesn\'t correspond to a day of the week.')
The program is an illustration of conditional statements.
Conditional statements are statements whose execution is dependent on the true values of its condition
The program in Python where comments are used to explain each line is as follows:
#This initializes a list of days
daysList = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
#This gets input for the day of the week
day = int(input("Day: "))
#If the input day is between 1 and 7 (inclusive)
if day >= 1 and day <=7:
#This prints the corresponding day
print(daysList[day - 1])
#Otherwise
else:
#The day is invalid
print("Invalid Input")
Read more about similar programs at:
https://brainly.com/question/16633870