This document contains the code for a Python program that takes in a number of arithmetic expressions as input, evaluates them, and simplifies any that can be simplified using basic algebraic rules like 0+a=a or a/1=a. It prints the simplified expressions.
This document contains the code for a Python program that takes in a number of arithmetic expressions as input, evaluates them, and simplifies any that can be simplified using basic algebraic rules like 0+a=a or a/1=a. It prints the simplified expressions.
This document contains the code for a Python program that takes in a number of arithmetic expressions as input, evaluates them, and simplifies any that can be simplified using basic algebraic rules like 0+a=a or a/1=a. It prints the simplified expressions.
b=[list(map(str,input().split())) for i in range(n)] ind=[] a=[] for i in range(n): opr=b[i][0] op1=b[i][1] op2=b[i][2] res=b[i][3] if(opr=='+' and (op1=='0' or op2=='0') and (res==op1 or res==op2)): ind.append(i) elif(opr=='-' and op2=='0' and res==op1): ind.append(i) elif(opr=='*' and (op1=='1' or op2=='1') and (res==op1 or res==op2)): ind.append(i) elif(opr=='/' and op2=='1' and res==op1): ind.append(i) for i in range(n): if(i not in ind): a.append(b[i]) print("after algebraic simplification:") for i in a: for j in i: print(j,end=' ') print('',sep='\n')