Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python lang. 1. Create a calculator app that will allow a user to add, subtract, multiply, and divide two numbers. The program will repeat,

in python lang.

image text in transcribedimage text in transcribed

1. Create a calculator app that will allow a user to add, subtract, multiply, and divide two numbers. The program will repeat, allowing the user to continuously use the app until they choose to quit the program. 2. Define four functions, each with 2 parameters, to carry out mathematical operations on two numbers: o plus: this function will add two numbers o minus: this function will subtract one number from another number o multiply: this function will multiply two numbers o divide: this function will divide one number by another number 3. Define the prompt_user function. This function will ask the user to enter either: add, subtract, multiply, divide. After the user chooses what they want to do, ask them for what numbers they want to use. Finally, call the appropriate function, passing it the user's input. o Allow the user to type in an option with any capitalization: subtract, SUBTRACT, SUBTRACT, etc should all be considered valid input. (See example below.) o Consider the possibility that the user might not type in one of the given choices! Do something about it. (See example below.) 4. Define the main function. This function will repeatedly call on the prompt_user function, allowing the user to continuously do math calculations until they choose to quit the program. 5. Write a goodbye or ending message when the user ends the program. 6. Be sure to add comments for each section of your code. 7. Make sure your output is descriptive. Tell the user what you're printing, don't just print out the answers alone. For example, if the user chooses to add 5 and 10. your output should state what numbers are being added: 5 + 10 = 15 Welcome to my calculator app! I can add, subtract, multiply, or divide two numbers ! Type your choice: add / subtract / multiply / divide add Okay, I'll add two numbers for you! Enter the first number: 5 Enter the second number: 15 5 + 15 = 20 Do another calculation? Type yes or no: yes Type your choice: add / subtract / multiply / divide SUBTRACT Okay, I'll subtract two numbers for you! Enter the first number: 700 Enter the second number: 500 700 - 500 = 200 Do another calculation? Type yes or no: YES Type your choice: add / subtract / multiply / divide multiply Okay, I'll multiply two numbers for you! Enter the first number: 3 Enter the second number: 4 3 * 4 = 12 Do another calculation? Type yes or no: yes Type your choice: add / subtract / multiply / divide modulo Uhhhh.. what? Sorry, I don't know what you mean! I'm just a simple little calculator, don't ask too much of me. :) Do another calculation? Type yes or no: no

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

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions