The document appears to be a computer program that takes in a number of quadruples (sets of 4 items) as input from the user. It then evaluates each quadruple using the operator and operands, performs the calculation, and replaces the original quadruple with the result. Finally it prints out the updated list of quadruples.
The document appears to be a computer program that takes in a number of quadruples (sets of 4 items) as input from the user. It then evaluates each quadruple using the operator and operands, performs the calculation, and replaces the original quadruple with the result. Finally it prints out the updated list of quadruples.
The document appears to be a computer program that takes in a number of quadruples (sets of 4 items) as input from the user. It then evaluates each quadruple using the operator and operands, performs the calculation, and replaces the original quadruple with the result. Finally it prints out the updated list of quadruples.
b=[list(map(str,input().split())) for i in range(n)] for i in range(n): opr=b[i][0] try: op1=int(b[i][1]) op2=int(b[i][2]) except ValueError: continue if(opr=='+'): res=op1+op2 b[i]=['=',res,'-',b[i][3]] elif(opr=='-'): res=op1-op2 b[i]=['=',res,'-',b[i][3]] elif(opr=='*'): res=op1*op2 b[i]=['=',res,'-',b[i][3]] elif(opr=='/'): res=op1/op2 res=int(res) b[i]=['=',res,'-',b[i][3]] print("after constant folding:") for i in b: for j in i: print(j,end=' ') print('',sep='\n')