Question: Calculator Function The first four functions are complete. The last function, calc(), is the one I am having trouble with. It is supposed to use
Calculator Function
The first four functions are complete. The last function, calc(), is the one I am having trouble with. It is supposed to use the previous functions to evaluate a string expression such as "4 - 3 + 5 / 4 * 2"
Comments explaining your thought process for each step and what the functions do would be great. This is on a very close time limit of the end of the night. I can't seem to get it to work. Thank you very much for your help.



def findNextOpr (s) must be a nonempty string. if len(s)0 or isinstance (s, str) ops= ['+', '-', '/', for i in range (len (s)) if s[i] in ops: return i return -1 #In this exercise +, -, *, / are all the 4 operators #The function returns -1 if there is no operator in s, #otherwise returns the position of the leftmost operator # code the rest of the function # - function code ends- def isNumber (s) #3 must be a non-empty string #returns True if it's convertible to float, else False if len(s)=-0 or not isinstance(s, str): print ("type mismatch error: isNumber") return "type mismatch error: isNumber" try: float (s) return True except: return False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
