Question: Examine the code written below. This program when running correctly will generate a random number between 1 and 1 0 0 and then ask the
Examine the code written below. This program when running correctly will generate a random number between and and then ask the user to guess it The user will have chances to guess the number. With each guess the program will give the user hints. The user can play the game multiple times. When the user guesses correctly the program will print out "You Win!". If the user guesses incorrectly the program will display "You Lose!".
Copy and paste the code into either IDLE or VS Code. Identify the five errors within this file by inserting comments in your code. After you have identified the bugs and fixed the code, upload it here to this question.
#Variables
guess int
randomNum int
chances int
UserContinue str
#Generate the random number
while UserContinue "yes":
randomNum random.randint
guess intinputEnter your guess
while chances :
if guess randomNum:
printYou Win!"
chances
elif guess randomNum:
printYour guess is higher than the chosen number."
guess intinputPlease enter another number
chances chances
else:
printyour guess is lower than the chosen number."
guess intinputPlease enter another number
chances chances
#end if
#end loop
#Ask the user if they want to continue
UserContinue inputDo you want to play again? Enter yes or no
#End loop
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
