Case Scenario: You are going to build a "reverse" guessing game in Python. You will think of a number, the computer will make a guess, and you will tell the computer if it was correct or to adjust its next guess higher or lower. The computer has 10 tries to guess your number. What Your Python Program Should Do: Your program will try to guess a number that the user is thinking of, between 1 and 20. Your program should accept input from the user as to whether its guess was too high or too low, and change its next guess accordingly. The computer has 10 tries to guess the number the user is thinking of. For each guess the computer makes: 1. Print a message telling the user what number the computer guessed. 2. Ask the user to enter "h" if the computer's guess was too high, “l” if the computer's guess was too low, or "c" if the computer's guess was correct. All letters are lowercase and without quotes. 3. If the computer's guess was correct, print a message telling the user how many guesses it took for the computer to guess the user's number correctly. Print a congratulations message and end your program. 4. If the computer's guess was too high, subtract from the guess a random number between 1 and 5. Use this new number as the next guess. Add some code to check if the new guess is below 0, and if it is, set the new guess equal to 1. 5. If the computer's guess was too low, add to the guess a random number between 1 and 5. Add some code to check if the new guess is above 20, and if it is, set the new guess equal to 20. 6. If the computer has reached the 10-guess limit, print a message saying that it was unable to guess the user's number in 10 tries. Important Things to Remember: - Tell the user each new guess and let the user continue providing input. The program must run until the user enters "c" (no quotes) or the computer reaches the 10-guess limit. Your program must include a for loop somewhere. No hardcoding allowed.
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
![Case Scenario:
You are going to build a "reverse" guessing game in Python. You will think of a number, the
computer will make a guess, and you will tell the computer if it was correct or to adjust its next
guess higher or lower. The computer has 10 tries to guess your number.
What Your Python Program Should Do:
Your program will try to guess a number that the user is thinking of, between 1 and 20. Your
program should accept input from the user as to whether its guess was too high or too low, and
change its next guess accordingly. The computer has 10 tries to guess the number the user is
thinking of.
For each guess the computer makes:
1. Print a message telling the user what number the computer guessed.
2.
Ask the user to enter “h” if the computer's guess was too high, “1” if the computer's
guess was too low, or "c" if the computer's guess was correct. All letters are lowercase
and without quotes.
3. If the computer's guess was correct, print a message telling the user how many guesses it
took for the computer to guess the user's number correctly. Print a congratulations
message and end your program.
4. If the computer's guess was too high, subtract from the guess a random number between
1 and 5. Use this new number as the next guess. Add some code to check if the new guess
is below 0, and if it is, set the new guess equal to 1.
5. If the computer's guess was too low, add to the guess a random number between 1 and 5.
Add some code to check if the new guess is above 20, and if it is, set the new guess equal
to 20.
6. If the computer has reached the 10-guess limit, print a message saying that it was unable
to guess the user's number in 10 tries.
Important Things to Remember:
Tell the user each new guess and let the user continue providing input.
The program must run until the user enters "c" (no quotes) or the computer reaches the
10-guess limit.
Your program must include a for loop somewhere.
No hardcoding allowed.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F62f0d6b3-be22-4c43-9203-57e115dc125e%2Fb8e5f64e-5165-4cfa-94b3-1e3e8ce499d2%2F4m9ue1_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)