Question: Python: import random n = random.randint(1, 20) numb = int(input(Enter an integer from 1 to 20: )) while n != numb: print if numb <

Python: import random n = random.randint(1, 20) numb = int(input("Enter an integer from 1 to 20: ")) while n != "numb": print if numb < n: print ("Too low.") guess = int(input("Enter an integer from 1 to 20: ")) elif numb > n: print ("Too high.") numb = int(input("Enter an integer from 1 to 20: ")) else: print ("You win!") break print 

Use random # game and improve:

Add:

1.Loop to run again.

2.Count the # of guesses made Win or lose, display # of guesses made

3.Check that the guess is:

a. A number

b. An integer

c. Range (1-20)

d. Issue error message and ask again

4.Default limit is 5 guesses

5.At beginning, ask for a limit to the # of guesses

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!