Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python please Calculator Have the function Calculator(str) take the str parameter being passed and evaluate the mathematical expression within in. For example, if str

in python please image text in transcribed
image text in transcribed
Calculator Have the function Calculator(str) take the str parameter being passed and evaluate the mathematical expression within in. For example, if str were "2+(3-1)*3" the output should be 8. Another example: if str were "(2-0) (6/2)" the output should be 6. There can be parenthesis within the string so you must evaluate it properly according to the rules of arithmetic. The string will contain the operators: +,-./,* (, and ). If you have a string like this: #/#*# or #+#(#)/#, then evaluate from left to right. So divide then multiply, and for the second one multiply, divide, then add. The evaluations will be such that there will not be any decimal operations, so you do not need to account for rounding and whatnot. Examples Input: "6*(4/2)+3*1" Output: 15 Input: "6/3-1" Output: 1 Python def Calculator(strParam): 1 2 3 4 5 6 # code goes here return strParam # keep this function call here print Calculator(raw_input()) 7

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_2

Step: 3

blur-text-image_3

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions