Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago