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
Answers: 2
Computers and Technology, 22.06.2019 12:00
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
Computers and Technology, 23.06.2019 23:30
What can you prevent issues related to downloading content form the internet
Answers: 1
Computers and Technology, 24.06.2019 15:30
What type of forensic evidence was recovered during the bomb set off at the new mexico facility on the video that was similar to the evidence obtained at the boston bombings and how did the evidence allow the researchers to connect other pieces of evidence to the same bomb?
Answers: 2
Computers and Technology, 24.06.2019 18:00
Explain the circumstances for which the interquartile range is the preferred measure of dispersion. what is an advantage that the standard deviation has over the interquartile range? choose the correct answer below. a. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it increases as the dispersion of the data increases. b. the interquartile range is preferred when the data are not skewed or no have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. c. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it is resistant to extreme values. d. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it is resistant to extreme values. e. the interquartile range is preferred when the data are skewed or have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. f. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it increases as the dispersion of the data increases.
Answers: 2
Modify the guessing-game program so that the user thinks of a number that the computer must guess.
English, 17.10.2019 12:20
Social Studies, 17.10.2019 12:20
Chemistry, 17.10.2019 12:20
History, 17.10.2019 12:20
Geography, 17.10.2019 12:20
History, 17.10.2019 12:20
Mathematics, 17.10.2019 12:20
Mathematics, 17.10.2019 12:20
Social Studies, 17.10.2019 12:20