Question: Python Create 3 variables named: guess compNum maxGuess Generate a random number in Python and store it in the variable compNum . Generate the number
Python
Create 3 variables named:
guess
compNum
maxGuess
Generate a random number in Python and store it in the variable compNum. Generate the number in the range of numbers you have selected. Ex 1 50, 1 100.
Prompt the user to guess a number between the range you selected. Ex. Guess a number between 1 and 100. Store this value in the variable guess.
Using the conditional structures you learned, compare the values and output to the user whether their guess is too low, too high or correct.
Using a looping structure, allow the user to guess the max number of attempts.
If the user exceeds the max number of attempts, output, Game Over!
If the user guesses correctly within the number of attempts allowed, output, You Win!
Print the result to the screen.
Run the code to display your output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
