Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started