Answered step by step
Verified Expert Solution
Link Copied!

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 1 and 100...
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 1 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 -1 at a prompt that says Level: and press Enter. Your program should reprompt you:
Level:
Run your program. Type 10 at a prompt that says Level: and press Enter. Your program should now be ready to accept guesses:
Guess:
Run your program. Type 10 at a prompt that says Level: and press Enter. Then type cat. Your program should reprompt you:
Guess:
Run your program. Type 10 at a prompt that says Level: and press Enter. Then type -1. Your program should reprompt you:
Guess:
Run your program. Type 1 at a prompt that says Level: and press Enter. Then type 1. Your program should output:
Just right!
Theres only one possible number the answer could be!
Run your program. Type 10 at a prompt that says Level: and press Enter. Then type 100. Your program should output:
Too large!
Looks like youre guessing outside the range you specified.
Run your program. Type 10000 at a prompt that says Level: and press Enter. Then type 1. 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

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

| Who are people who model the values that I want to live?

Answered: 1 week ago

Question

| In what ways am 1 striving to make their lives better?

Answered: 1 week ago