Answer to Question #257125 in Python for Hiruni

Question #257125
You are required to implement a simple symbolic equation solver. The equation must be stored in a binary tree. Each operand or operator should be stored as a tuple of the form (TYPE, VALUE). For example: (OPERAND, 5), (OPERAND, 7), (OPERAND, 34), (OPERATOR, ‘+’) or (OPERATOR, '*’'). Following operators should be supported: addition (+), subtraction (-), multiplication (*), and exponentiation (^). Skeleton of this lab exercise is given below. Complete the bodies of the insert, and evaluate methods. Include your solution in the sections mentioned as
1
Expert's answer
2021-10-26T17:28:23-0400
def sym_maths(x,y):
    list1 = ['+', '-', '*', '^']
    input1 = input('Enter operator here: ')
    if input1 == '+':
        return x+y
    elif input1 == '*':
        return x * y
    elif input1 == '-':
        return x-y
    else:
        return x**y

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS