Question: By using an if - elif - else structure, write a program that reads a number entered by the user. The entered number should be

  • By using an if-elif-else structure, write a program that reads a number entered by the user.
    • The entered number should be in the range 1 6.
  • The number entered by the user should then be checked to make sure it is in the right range.
  • If a user enters a number outside of the range 1 6, then your program should display the following message and exit:

Sorry, number is out of range.

[Replacing number with the value the user entered.]

If they entered a number in the range, the appropriate message should be displayed:

Range

Message

1, 3, or 5

Odd number

2, 4, or 6

Even number

Not within 1 6

Invalid number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!