subject
Computers and Technology, 06.12.2019 22:31 bob7220

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: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
Consider the following function main: int main() { int alpha[20]; int beta[20]; int matrix[10][4]; . . } a. write the definition of the function inputarray that prompts the user to input 20 numbers and stores the numbers into alpha. b. write the definition of the function doublearray that initializes the elements of beta to two times the corresponding elements in alpha. make sure that you prevent the function from modifying the elements of alpha. c. write the definition of the function copyalphabeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. make sure that you prevent the function from modifying the elements of alpha and beta. d. write the definition of the function printarray that prints any onedimensional array of type int. print 15 elements per line. e. write a c11 program that tests the function main and the functions discussed in parts a through d. (add additional functions, such as printing a two-dimensional array, as needed.)
Answers: 3
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
question
Computers and Technology, 25.06.2019 08:00
Most computers today support the standard, in which the computer automatically configures new devices as soon as they are installed and the pc is powered up.
Answers: 1
question
Computers and Technology, 26.06.2019 02:00
Give a detailed easy to understand explanation what the kerneltrapmode is. will award brainliest!
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
English, 27.11.2019 16:31
question
Physics, 27.11.2019 16:31
Questions on the website: 13722361