Question: Write a python program in which the computer thinks of a random number from 1 to 2 0 and askes you to guess it .

Write a python program in which the computer thinks of a random number from 1 to 20 and askes you to guess it. The computer will tell you if each guess is too high or too low. You win if you can guess the number within five tries. As closely as possible, follow the examples below.
Import the radint function from the random library. (See Unit 5)(10 points)(Hint: use randint)
Prompt for the user's name. (10 points)(Hint: use an input statement)
Display a greeting with the user's name and the number of guesses. (10 points)(Hint: use a print statement)
Have the computer generate a random number between 1 and 20.(See Unit 5)(10 points)(Hint: use randint)
Play the game for 5 rounds. (20 points)(Hint: use a FOR or a While Loop)
Prompt the user for a guess. (10 points)(Hint use an input statement and convert input to an integer)
If the guess is greater than the random number, print a message. (20 points)(Hint: use an IF statement and a print statement)
If the guess is less than the random number, print a message. (20 points)(Hint: use an IF statement and a print statement)
If the guess is equal to the random number, print a message with the user name and the number of guesses used. The game ends. (20 points)(Hint: use an IF statement and a print statement)
If the user exceeds the number of guesses, print a message with the random number. The game ends. (20 points)(Hint: use an IF statement and a print statement)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!