Question: To practice a simple loop and simple conditionals For this question, you ll write a simple program that makes the user try to guess a

To practice a simple loop and simple conditionals
For this question, youll write a simple program that makes the user try to guess a secret number repeatedly
until they get it right.
First, your program should select a random number between 1 and 10(inclusive). You can use the randint()
method from the random module to do this. This is the secret number that the user is trying to guess.
Then, your program should allow the user to input numbers as many times as needed in order to guess the
secret number. If the user gets it wrong, the program should give a hint by telling the user whether their
guess was too high or too low. If the user gets it right, the program should tell them so and then terminate.
Sample Run
Sample input and output (input typed by the user is shown in green text):
Guess a number from 1 to 10!5
Too low !
Guess again : 7
You got it , the secret number was 7

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!