Question
Write a python program to play the guess the number game. The computer will pick a magic number between 1 and 100 and the user
Write a python program to play the guess the number game. The computer will pick a magic number between 1 and 100 and the user will try to guess the number in as few guesses as possible. The program will keep asking for a guess until the magic number is entered by the user. The program will also give hints to the user (hot or cold) based on whether the new guess is closer or further to the magic number compared to the previous guess. For the first guess, it will be assumed the previous guess is 50. The program will output the number of guesses.
Below is a sample run of how the program should proceed:
I am thinking of a number between 1 and 100. Can you guess what the number is? Enter your guess: 40 Cold! Enter your guess: 75 Hot! Enter your guess: 87 Hot! Enter your guess: 82 You win! You solved it in 4 guesses.
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