Write a python program that is a simple guessing game. You will pick a number between 1 and 100, then give you 5 guesses. If you guess right, it will say “You win!”. If you guess higher or lower than...

Write a python program that is a simple guessing game. You will pick a number between 1 and 100, then give you 5 guesses. If you guess right, it will say “You win!”. If you guess higher or lower than correct, it will say “The number is higher than that.” (or lower). If after five guesses they still don’t know the number, print “You lose; the number was x.” where x was the number you were to guess. Before the game begins, ask what number to pick. If you say “-1”, pick randomly; otherwise, use their number even if it is outside the 1–100 range. Get a random integer by using the random.randint() method. (Bold numbers represent the numbers that the user enters for the game) An example run of the program might look like: What should the answer be?: 19 Guess a number: 9 The number is higher than that. Guess a number: 40 The number is lower than that. Guess a number: 19 You win! Another run might look like: What should the answer be?: -1 Guess a number: 5 The number is higher than that. Guess a number: 100 The number is lower than that. Guess a number: 50 The number is lower than that. Guess a number: 25 The number is lower than that. Guess a number: 12 You lose; the number was 7.

May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here