Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Modify the guessing-game program so that the user thinks of a number that the computer must guess. The computer must make no more than

image text in transcribed Instructions Modify the guessing-game program so that the user thinks of a number that the computer must guess. The computer must make no more than the minimum number of guesses, and it must prevent the user from cheating by entering misleading hints. Use I'm out of guesses, and you cheated and Hooray, I've got it in X tries as your final output. (Hint: Use the math.log function to compute the minimum number of guesses needed after the lower and upper bounds are entered.) # Modify the code below: import random smaller = int(input("Enter the smaller number: ")) larger = int(input("Enter the larger number: ")) myNumber = random.randint(smaller, larger) count = 0 while True: count += 1 userNumber = int(input("Enter your guess: ")) if userNumber myNumber: print("Too large") else: print("You've got it in", count, "tries!") break

+guess.py Instructions Modify the guessing-game program so that the user thinks of a number that the computer must guess 1 # Modify the code below 2 import randon 3 4 smaller int(input("Enter the snaller number:)) 5 larger -int(input( "Enter the larger number:") The computer must make no more than the minimum number of guesses, and it must prevent the user from cheating by entering misleading hints Use I'n out of guesses, and you cheated and Hooray, I've got it in X tries as your final output. 7 myNumber random.randint (snaller, larger) 8 count 9 while True 10 count +: 1 userNumber int(input("Enter your guess:) if userNumbermyNumber 12 13 14 15 16 17 18 19 20 print("Too small") print("Too large") print("You ve got it in", count, "tries!") elif userNumber > nyNumber (Hint: Use the math.log function to compute the minimum number of guesses needed after the lower and upper bounds are entered.) else break Below are two test runs of the program Enter the smaller number: 0 Enter the larger number: 10 Your number is 5 Your number is 2 Run Code Test Grade Your number is 3

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_2

Step: 3

blur-text-image_3

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

Can troubleshooting be accomplished easily with the documentation?

Answered: 1 week ago

Question

LO4 Provide an overview of four challenges facing HR today.

Answered: 1 week ago