Write a program that first asks whether the user wants to play the game of adding two numbers. If the user says "y" then it should generate two random integers between 1 and 100 (use the method you used in the lab earlier). It should show the numbers to the user and ask the user to mentally add them and give the answer. If the user answers incorrectly then the program should ask the user to try it again, it should keep asking till the user answers the sum correctly. After that the program should ask whether the user wants to play the game again till user says "n". Hint: This program will require using two nested loops. Following is a sample run of the program:
Write a program that first asks whether the user wants to play the game of adding two numbers. If the user says "y" then it should generate two random integers between 1 and 100 (use the method you used in the lab earlier). It should show the numbers to the user and ask the user to mentally add them and give the answer. If the user answers incorrectly then the program should ask the user to try it again, it should keep asking till the user answers the sum correctly. After that the program should ask whether the user wants to play the game again till user says "n". Hint: This program will require using two nested loops. Following is a sample run of the program:
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Python

Transcribed Image Text:**Interactive Math Game: Summing Two Numbers**
Welcome to the interactive math game designed to help you practice adding two numbers. Below is an example session showing how the game works:
---
**Question**: Do you want to play the game and add two numbers? (y/n)
**Response**: y
- **Round 1**
- The two numbers are 69 and 8
- What is the sum of the two numbers?
- **Attempt 1**: 76
- *Feedback*: Your answer is incorrect.
- **Attempt 2**: 77
- *Feedback*: Your answer is correct!
**Question**: Do you want to play the game again? (y/n)
**Response**: y
- **Round 2**
- The two numbers are 33 and 50
- What is the sum of the two numbers?
- **Attempt 1**: 73
- *Feedback*: Your answer is incorrect.
- **Attempt 2**: 93
- *Feedback*: Your answer is incorrect.
- **Attempt 3**: 83
- *Feedback*: Your answer is correct!
**Question**: Do you want to play the game again? (y/n)
**Response**: y
- **Round 3**
- The two numbers are 90 and 41
- What is the sum of the two numbers?
- **Attempt 1**: 131
- *Feedback*: Your answer is correct!
**Question**: Do you want to play the game again? (y/n)
**Response**: n
---
Feel free to play as many rounds as you like to improve your addition skills!

Transcribed Image Text:**Programming Exercise: Addition Game**
**Objective:**
Write a program that asks the user if they want to play a game that involves adding two numbers.
**Instructions:**
1. The program should prompt the user with a question to determine if they want to play the game.
2. If the user responds with "y", the program will generate two random integers between 1 and 100.
3. Display the numbers to the user and prompt them to mentally add the numbers and provide the sum.
4. If the user provides an incorrect sum, the program will prompt them to try again. This should continue until the user provides the correct sum.
5. After a correct answer, ask the user if they want to play again. Continue the process until the user responds with "n".
**Hint:** This program will require the use of two nested loops.
**Example Execution:**
```plaintext
Do you want to play the addition game? (y/n): y
Add these two numbers: 23 + 47
Your answer: 70
That's incorrect. Try again.
Add these two numbers: 23 + 47
Your answer: 70
That's incorrect. Try again.
Add these two numbers: 23 + 47
Your answer: 70
Correct!
Do you want to play again? (y/n): n
```
Use this example as a guide to structure your program and user interaction efficiently.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education