Question
Guessing Game Lab The local circus is having money trouble, and needs to cut back on their performers. The sideshow psychic who tried to guess
Guessing Game Lab The local circus is having money trouble, and needs to cut back on their performers. The sideshow psychic who tried to guess everyone's weight never did a good job at it anyway, so they've fired him and are asking you to write a program to do the job. The program must randomly generate a number between 1 and 500. That number will be given to the user as the guess for their weight. The user will tell the program is the guess is correct, high, or low. If the guess is correct, display the number of guesses it took to get the right weight. If the guess is high or low, continue making guesses, until the program gets it right. Smart Guessing Your program must guess intelligently. For example, if the program guesses the user's weight at 35, and the user tells the program that guess is low, the program should never guess 35 or below again. The range of guesses will narrow as more guesses are made, until the program has it narrowed down to a single number. Random Numbers To generate random numbers, use the random module from Python. For example, to generate a random number from 1 to 100: import random low = 1 high = 100 number = random.randint(low, high) The import random must only be done once, at the very top of the module. Every time you call random.randint, you get a new random number. Functions You must define functions and use the algorithm techniques that we've been studying to make the code easy to read.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started