Python programming exercise 3.3 (guess.py)
Modify the guessing-game program so that the user thinks of a number that the computer must guess.
#guess.py import random print("Guessing game between 1 and 100.") print("Can you guess what the number is?") min_number = 1 max_number = 100 rand = random.randint(min_number,max_number) count = 0 while(True): guess = eval(input("Enter your guess: ")) count += 1 if(guess == rand): print("You win!") break elif(guess < rand): print("Too low") else: print("Too high") print("You solved it in",count,"guesses.")
Get Answers For Free
Most questions answered within 1 hours.