subject

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.)

And here is the code i wrote that works until one point:

# Modify the code below:
import random
import math

smaller = int(input("Enter the smaller number: "))
larger = int(input("Enter the larger number: "))

count = 0

print()
while True:
count += 1
myNumber = (smaller + larger) // 2
print('%d %d' % (smaller, larger))
print('Your number is %d' % myNumber)
choice = input('Enter =, <, or >: ')
if choice == '=':
print("Hooray, I've got it in %d tries" % count)
break
elif smaller == larger:
print("I'm out of guesses, and you cheated")
elif choice == '<':
larger = myNumber - 1
else:
smaller = myNumber + 1

This guessing game works up until this question:

Failed: Test 0-50, when 1 is picked then switched when correctly guessed.

This is the input the automater did:

Enter the smaller number: Enter the larger number:
0 50
Your number is 25
Enter =, <, or >: 0 24
Your number is 12
Enter =, <, or >: 0 11
Your number is 5
Enter =, <, or >: 0 4
Your number is 2
Enter =, <, or >: 0 1
Your number is 0
Enter =, <, or >: 1 1
Your number is 1
Enter =, <, or >: I'm out of guesses, and you cheated
1 1
Your number is 1
Enter =, <, or >:
Traceback (most recent call last):
File "guess. py", line 16, in
choice = input('Enter =, <, or >: ')
EOFError: EOF when reading a line

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:10
Type the correct answer in the box. spell all words correctly. which technology should andrea use? andrea owns a potato chips manufacturing unit. she has been getting complaints about the quality of the chips. she knows her product is good. she realizes that she needs to change the way the chips are packaged. she should use technology, which uses gases, such as carbon dioxide or argon, to create an air cushion, which improves the shelf life of products.
Answers: 2
question
Computers and Technology, 21.06.2019 22:30
The blank is type of decision-maker who over analyzes information
Answers: 3
question
Computers and Technology, 22.06.2019 14:20
Cengagenowv2 is a comprehensive online learning tool. using cengagenowv2, you may access all of the following except: 2. each time you log in, cengagenowv2 automatically performs a system check and informs you if your computer does not meet the cengagenowv2 system requirements. 3. which tab/page allows you to easily track your assignment scores, number of submissions, time spent, as well as the ability view assign
Answers: 3
question
Computers and Technology, 22.06.2019 19:10
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
You know the right answer?
Modify the guessing-game program so that the user thinks of a number that the computer must guess.
Questions
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Biology, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
English, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01
question
Mathematics, 16.09.2020 16:01