Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is what I have so far. I just need help with the play again part. How do I make it read the loop again?

image text in transcribed
image text in transcribed
This is what I have so far. I just need help with the play again part. How do I make it read the loop again? Im a beginner
Random Number Guessing Game Create a game (guess,py) where the computer randomly picks a number between 0 and 20. Use the following code to generate a random number for the computer. import random # Place this command at that top of your program number- random . rand int (1, 20) #will generate a number including 1 and 20 Then the user is asked to guess a number between 1 and 20 .If the guess is less than the computer-picked number, then the user is informed that their guess is lower . If the guess is greater than the computer-picked number, then the user is informed that their guess is higher . If the guess is equal to the computer-picked number, then the user is informed that they have correctly guessed the number. You should also let the user know how many guesses were required to accurately guess the number. The user can have five guesses at most, after which the computer-picked number is displayed to the user. If the user guesses the number correctly at any point, then you must stop asking the user ta make more guesses. If the user has guessed the corect number or if they had have five tries, your program must now ask the user if s/he would like to play again (y) If the user presses a 'y', then the program must generate a new random number and ask 1 import random 2 number- random. randint (1,20) 3 guesses_taken- 5 while guessestaken 20: 12 elif guess number: 14 else 15 16 17 if guess-number: 18 print("CORRECT! :D You are given 5 guesses to accurately guess the number") 19 else: 20 print("Correct number was", number) 21 print("Better luck next time :(") 23

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions