Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(python pls) Write a program that will treat an equation like a stack. It will p

ID: 3606292 • Letter: #

Question

(python pls) Write a program that will treat an equation like a stack. It will pop each character off of the stack to evaluate whether it is an operation, variable, constant or parenthesis. You will need to initialize each variable (with values prior to parsing the string which makes up the equation. I need it to be able to determine and print out which is a operation , a variable, constant and parenthesis.using trig functions also to be able to solve (sin(sin(sin(sin(x))))) as well as 5X(T/3)-X.

Explanation / Answer

here's the code required :

----------------------------------------------------------------------------------------------------------------

#!usr/bin/env python


# reading the variables
variables = raw_input("Enter the variables that are used in the equation :").split(' ')

# reading the constants
constants = raw_input("Enter the constants that are used in the equation :").split(' ')

# reading the operation symbols
operations = raw_input("Enter the operations that are used in the equation :").split(' ')

# reading the expression
expression = raw_input("Enter the expression :")

# reading the expression from last charecter

for i in range(len(expression)-1,0,-1):
        c = expression[i];
        if c in variables:
                print "A varaible",
                print c
        elif c in constants:
                print "A constant",
                print c
        elif c in operations:
                print "An operation",
                print c

--------------------------------------------------------------------------------------------------------------

/* hope this helps */

/* if any queries please comment */

/* thank you */