Question: Please answer it in Python we will now develop a small game whose rules are as follows: The program draws a random number between 0

Please answer it in Python

we will now develop a small game whose rules are as follows:

The program draws a random number between 0 and 100 inclusive and does not display it on the screen.

The player must guess the value of this number by typing his proposal on the keyboard.

The program displays as appropriate:

"Won" if the player has guessed the right number. The program ends immediately.

"Too big" if the player has entered a number larger than the right price.

"Too small" if the player has entered a number smaller than the right price

- The player has only 5 tries before the program ends by displaying the

message 'Lost!'. If the player wins after X tries, the program should display "Won after X tries!".

. at the end of each game, the message "Do you want to start again? (y/n)" is displayed.

If the user types 'y', a new part of the game starts, if he types 'n', the program ends by displaying

how many tries it took the player on average (over all the games played) to find the right answer.

Example :

Guess the mysterious number! 50

Too small!

Try again: 75

Too small!

Try again: 82

Too big!

Try again: 78

Won after 4 tries!

The mysterious number was indeed 78 .

Do you want to do it again? (y/n) y

Guess the mysterious number! 50

Too big!

Try again: 25

Too big!

Try again: 12

Won after 3 tries!

The number mystere was well 12 .

Do you want to do it again? (y/n) n

Finished. Number of average tests: 3.5

Please answer it in Python

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!