Your program shall generate a random arithmetic expression based on a user's level (this should range from 2-5). Use the level number to determine the number of operands in the expression ex. level 2 generates expression of the form 2-5 The program shall display the generated expression and collect user input for an answer to the expression. The program shall compare the user's given answer to the program evaluated result (round to 2dp), and print the outcome: ie. invalid input, wrong answer (different from computed value) or right answer (equal to computed value within 2dp) Your program shall allow user to repeat this process in one run of the application (keep track of number of sessions for each run)
Your program shall generate a random arithmetic expression based on a user's level (this should range from 2-5). Use the level number to determine the number of operands in the expression ex. level 2 generates expression of the form 2-5 The program shall display the generated expression and collect user input for an answer to the expression. The program shall compare the user's given answer to the program evaluated result (round to 2dp), and print the outcome: ie. invalid input, wrong answer (different from computed value) or right answer (equal to computed value within 2dp) Your program shall allow user to repeat this process in one run of the application (keep track of number of sessions for each run)
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
please do it in python language
first picture is problem and second one is just hint for you.
thanks
Expert Solution
Step 1
Algorithm:
- Take input from the user for the level (2-5)
- Generate a random expression based on the level using the "generate_expression" function
- Display the generated expression
- Collect user input for an answer to the expression
- Evaluate the expression using the "evaluate_expression" function
- Compare the user's given answer with the program-evaluated result using the "check_answer" function
- Print the outcome: "Invalid input", "Wrong answer" or "Right answer"
- Repeat the process until the user chooses to exit
- Keep track of the number of sessions
- Display the total number of sessions when the user chooses to exit.
Step by step
Solved in 4 steps with 3 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