Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python Guessing Game I m thinking of a number between 1 and 1 0 0 . . . What is it ? Implement a program
Python Guessing Game
Im thinking of a number between and
What is it
Implement a program that:
Prompts the user for a level, n If the user does not input a positive integer, the program should prompt again.
Randomly generates an integer between and n inclusive, using the random module.
Prompts the user to guess that integer. If the guess is not a positive integer, the program should prompt the user again.
If the guess is smaller than that integer, the program should output Too small! and prompt the user again.
If the guess is larger than that integer, the program should output Too large! and prompt the user again.
If the guess is the same as that integer, the program should output Just right! and exit.
Must include comments with your name, date, program name, and program purpose.
Hints
How to Test
Heres how to test your code manually:
Run your program. Type cat at a prompt that says Level: and press Enter. Your program should reprompt you:
Level:
Run your program. Type at a prompt that says Level: and press Enter. Your program should reprompt you:
Level:
Run your program. Type at a prompt that says Level: and press Enter. Your program should now be ready to accept guesses:
Guess:
Run your program. Type at a prompt that says Level: and press Enter. Then type cat. Your program should reprompt you:
Guess:
Run your program. Type at a prompt that says Level: and press Enter. Then type Your program should reprompt you:
Guess:
Run your program. Type at a prompt that says Level: and press Enter. Then type Your program should output:
Just right!
Theres only one possible number the answer could be
Run your program. Type at a prompt that says Level: and press Enter. Then type Your program should output:
Too large!
Looks like youre guessing outside the range you specified.
Run your program. Type at a prompt that says Level: and press Enter. Then type Your program should output:
Too small!
Most likely, anyways: you might get lucky and see Just right!. But it would certainly be odd for you to see Just right! every time. And certainly you shouldnt see Too large!.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started