Question: PYTHON Q#5 Write a program that asks the user to enter an a number between 1 and 36, and then compare it to a randomly

PYTHON

Q#5 Write a program that asks the user to enter an a number between 1 and 36, and then compare it to a randomly generated integer number between 1 and 36. If two numbers are equal, the program should display "WIN", otherwise it should display "LOSE" and then show the randomly generated number. Your program should contain the following functions:

  1. A function that generates an integer number between 1 and 36
  2. A function that computes number entered by user and randomly generated number and display the right message.
  3. A main( ) function that keeps asking the user to enter a number between 1-36 and uses the two functions above to report whether or not the user wins the game. If the user enters 0, the program should stop asking for a new number.

Here is an example:

input: Please enter a number between 1 and 36 (enter 0 to stop the program): 12

output: "LOSE", the winner number is 22

input: Please enter a number between 1 and 36 (enter 0 to stop the program): 1

output: "LOSE", the winner number is 36

input: Please enter a number between 1 and 36 (enter 0 to stop the program): 10

output: "WIN"

input: Please enter a number between 1 and 36 (enter 0 to stop the program): 0

output: Thank You!

Note: Since the numbers are generated randomly, your output will be different from the example above.

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!