165,701 views
39 votes
39 votes
PAssignment explanation

In this assignment, you need to implement a Python program using a function that takes the expression as
parameter and return the results.
1. Implements a calculator with the following functionality:
O
Can support the following operations: +- ***/ // %.
O
Do the math and find the result using the PEMDAS rules learned in the lecture and in high
school calculus
O Supports both integers and floats and returns the result in float format with a
precision of 2 decimal places.
2. The program does NOT ask the user for inputs one after another! Rather, it asks the user to enter
a string containing the entire mathematical operation he/she wishes to perform as follows:
Calculator:
User:
Please enter the mathematical expression you want the program to evaluate:
2.5 +3-10/4 **3 // 2 +99.1-9% 3
3. Once user finishes the calculation, the calculator should ask the user if he has more operations to
do or not.
4. If the user is done with calculations, the calculator should give a summary of the all the operations
done in this calculation session along with the output results as follows:
|Operation no. |
|1
12
|3
I
1
CALCULATOR OPERATIONS HISTORY
1
2.5 +3-10/4 ** 3 // 2 +99.1-9% 3 |
98.1/3 +9-3.3 ** 2 +44
100 * 9+3** 8/9
operation expression
1
operation output |
104.6
74.81
1629.0
NOTE: the data above is JUST an example, your code MUST accept user input for different strings that
follow the format mentioned in step 2 and successfully do the extraction and display of the output in a
similar way to what is shown in step 4. The grader will enter different inputs to test your code to assure
its success in accomplishing the assignment objective.
IMPORTANT: you are NOT allowed to use any Python built-in (or even available online)
module function that performs the above requirement, such as eval or similar. You MUST do
it yourself PYTHON PROGRAM

User Hholtij
by
2.6k points

1 Answer

21 votes
21 votes

Answer:

yes

Step-by-step explanation:

program using a function that takes the expression as

parameter and return the results.

1. Implements a calculator with the following functionality:

O

Can support the following operations: +- ***/ // %.

O

Do the math and find the result using the PEMDAS rules learned in the lecture and in high

school calculus

O Supports both integers and floats and returns the result in float format with a

precision of 2 decimal places.

2. The program does NOT ask the user for inputs one after another! Rather, it asks the user to enter

a string containing the entire mathematical operation he/she wishes to perform as follows:

Calculator:

User:

Please enter the mathematical expression you want the program to evaluate:

2.5 +3-10/4 **3 // 2 +99.1-9% 3

3. Once user finishes the calculation, the calculator should ask the user if he has more operations to

do or not.

4. If the user is done with calculations, the calculator should give a summary of the all the operations

done in this calculation session along with the output results as follows:

|Operation no. |

|1

12

|3

I

1

CALCULATOR OPERATIONS HISTORY

1

2.5 +3-10/4 ** 3 // 2 +99.1-9% 3 |

98.1/3 +9-3.3 ** 2 +44

100 * 9+3** 8/9

operation expression

1

operation output |

104.6

74.81

1629.0

NOTE: the data above is JUST an example, your code MUST accept user input for different strings that

follow the format mentioned in step 2 and successfully do the extraction and display of the output in a

similar way to what is shown in step 4. The grader will enter different inputs to test your code to assure

its success in accomplishing the assignment objective.

IMPORTANT: you are NOT allowed to use any Python built-in (or even available online)

module function that performs the above requirement, such as eval or similar. You MUST do

it yourself PYTHON PROGRAM

User Charles Grunwald
by
3.1k points