Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Python to solve it! Your goal is to make a simple calculator. It must add, subtract, multiply, divide, and find the solution to a

Use Python to solve it!

Your goal is to make a simple calculator. It must add, subtract, multiply, divide, and find the solution to a quadratic equation.

In main():

Depending on what the user inputs, you will call calculator to perform the operation.

The user inputs the operation they want to do +, -, *, /, or quad. It should be followed by the numbers the operation will be performed on.

Note:

addition, subtraction, multiplication and division require only 2 inputs

Solving for the "quadratic equation requires 3 inputs. (in this case inputs are a,b & c)

If 1 solution, print one value, if 2 solutions print 2 values

After getting the result, print on console, if q is an input, the program exits. In case when you encounter error, print ERROR

but the program should not quit.

In calculator():

There should be no print statements in this function, as you will only return the result. You should call the corresponding helper function to perform the operations. Then, the result will be returned to main().

Note:

Your program should handle some exception cases and return ERROR, such as

Invalid operation choice

Invalid arithmetic calculation

Please comment your code and provide at least one output for each possible operation

IMPORTANT:

Every operation NEEDS to have their own function. The number of inputs MUST BE the same number of arguments in the parameter. NO OTHER OUTPUTS/PRINT STATEMENTS. We are going to test your code(calculator() and main() function) so it should follow the EXACT format to the example below, including the spacing between each operation(makes it cleaner). Again you must have a function called main().

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 Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

Identify the seven data privacy best practices.

Answered: 1 week ago

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago

Question

How would you assess the value of an approach like this?

Answered: 1 week ago