Go: package main

import (
	"bufio"
	"fmt"
	"go/token"
	"go/types"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	for i := 0; i < n; i++ {
		stdin.Scan()
		exp := strings.TrimRight(stdin.Text(), "=")
		res, _ := types.Eval(token.NewFileSet(), nil, token.NoPos, exp)
		fmt.Println(res.Value)
	}
}

Python: for _ in[0]*int(input()):print(eval(input()[:-1]))

Python: # -*- coding: utf-8 -*-

import sys
import os
import math
import re

class Num:
    def __str__(self):
        return str(self.x)

    def __init__(self, value):
        self.x = value

    def __add__(self,value):
        return Num(self.x + value.x)

    def __sub__(self, value):
        return Num(self.x - value.x)

    def __mul__(self, value):
        return Num(self.x * value.x)

    def __truediv__(self,value):
        return Num(int(self.x / value.x))

n = int(input())

for i in range(n):
    command = input().strip()
    command = command.replace('=', '')
    command = re.sub(r'(\d+)', r'Num(\1)', command)
    print(eval(command))

# Supplement
"""
>>> math.floor(0.5)
0
>>> -1 // 2
-1
>>> int(0.5)
0
>>> int(-0.5)
0
"""

Python: from collections import deque

def eva(l, r, op):
    if op == "+":
        return l + r
    elif op == "-":
        return l - r
    elif op == "*":
        return l * r
    elif op == "/":
        return l // r


def calc(exp,brac=None):
    i = 0 # ループカウンタ?
    num = deque() # 数字をためておく
    ops = deque() # +-をためておく
    ope = "" # */を保存
    
    if not brac:
        # 対応する括弧の位置を記録しておいて計算量を削減
        brac = [-1 for j in range(len(exp))]
        tmpbrac = []
        for j in range(len(exp) - 1, 0, -1):
            if exp[j] == ')':
                tmpbrac.append(j)
            elif exp[j] == '(':
                brac[j] = tmpbrac.pop()

    # かっこの中身と乗除算
    while i < len(exp):
        # かっこの中身は再帰的に計算
        if exp[i] == '(':
            num.append(calc(exp[i + 1:brac[i]],brac))
            i = brac[i]
            if ope:
                r = num.pop()
                l = num.pop()
                num.append(eva(l, r, ope))
                ope = ""
        elif exp[i] in ["*", "/"]:
            ope = exp[i]
        elif exp[i] in ["+", "-"]:
            ops.append(exp[i])
        elif exp[i] == "=":
            pass
        else:
            temp = "" # 数値 2桁以上にも対応させる
            while i < len(exp) and exp[i].isnumeric():
                temp += exp[i]
                i += 1
            i -= 1 # 最後の数字に戻る(最後にi+=1しているのでこれでいい)
            num.append(int(temp))
            if ope:
                r = num.pop()
                l = num.pop()
                num.append(eva(l, r, ope))
                ope = ""
        i += 1
    while len(ops) != 0:
        num.appendleft(eva(num.popleft(),num.popleft(),ops.popleft()))

    return num[0]


n = int(input())
for i in range(n):
    exp = input()
    print(calc(exp))

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp
"""
import sys


def solve(exp):
    exp = exp.replace('=', '')
    #exp = exp.replace('/', '//')
    return int(eval(exp))


def main(args):
    n = int(input())
    for _ in range(n):
        expression = input().strip()
        result = solve(expression)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: def calc(eqt): # assuming that eqt has no brackets.
  l = eqt.split("+",maxsplit=1)
  if len(l) == 2: # if eqt has "+", then
    return (calc(l[0])+calc(l[1]))
  l = eqt.split("-",maxsplit=1)
  if len(l) == 2:# if eqt has "-", then
    return (calc(l[0])-calc(l[1]))
  l = eqt.split("*",maxsplit=1)
  if len(l) == 2:# if eqt has "*", then
    return (calc(l[0])*calc(l[1]))
  l = eqt.split("/",maxsplit=1)
  if len(l) == 2:# if eqt has "/", then
    return (calc(l[0])//calc(l[1]))
  return (int(eqt))

def unfold_brackets(eqt): # for example, eqt == "((3+5)*8+2)*2"
  l = eqt.split(')',maxsplit=1)
  if len(l) == 1: # if eqt has no brackets, then
    return calc(eqt)
  else:
    # for example, l == ["((3+5", "*8+2)*2"]
    ll = l[0].rsplit('(',maxsplit=1)
    # ll == ["(","3+5"]
    ll.append(l[1])
    # ll == ["(","3+5","*8+2)*2"]
    ll[1] = str(calc(ll[1]))
    # ll == ["(",8,"*8+2)*2"]
    l="".join(ll)
    # ll == "(8*8+2)*2"
    return unfold_brackets(l)

while True:
  try:
    n=int(input())
    datasets=[input() for i in range(0,n)]
    for line in datasets:
      l = line.split("=",maxsplit=1)[0]
      print(unfold_brackets(l))
  except EOFError:
    break

Python: def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

# Convert String to List
def String2List(s):
    L = []; tmp = ""
    for i in s:
        if i.isdigit():
            tmp += i
        else:
            if tmp != "":
                L.append(tmp)
                tmp = ""
            L.append(i)
    if tmp != "":
        L.append(tmp)

    return L

# generate Reverse Polish Notation
def Generate_RPN(L):
    S, L2 = [], []
    table = {"*": 1, "/": 1, "+": 0, "-": 0, "(": -1, ")": -1}
    for i in L:
        if i.isdigit():
            L2.append(i)
        elif i == "(":
            S.append(i)
        elif i == ")":
            while S[-1] != "(":
                L2.append(S.pop())
            S.pop()
        else:
            while len(S) != 0 and (table[S[-1]] >= table[i]):
                L2.append(S.pop())
            S.append(i)

    while len(S) != 0:
        L2.append(S.pop())

    return L2

Nline = int(input())
for ll in range(Nline):

    S = input()
    p = Generate_RPN(String2List(S[0:-1]))
    N = len(p)

    s = []
    for i in range(len(p)):
        if p[i] == "+":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(b+a))
        elif p[i] == "-":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(b-a))
        elif p[i] == "*":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(b*a))
        elif p[i] == "/":
            a = int(s.pop())
            b = int(s.pop())
            s.append(str(int(b/a)))
        else:
            s.append(p[i])
    print(s[0])

Python: def calc(eqt): # assuming that eqt has no brackets.
  l = eqt.split("+",maxsplit=1)
  if len(l) == 2: # if eqt has "+", then
    return (calc(l[0])+calc(l[1]))
  l = eqt.split("-",maxsplit=1)
  if len(l) == 2:# if eqt has "-", then
    return (calc(l[0])-calc(l[1]))
  l = eqt.split("*",maxsplit=1)
  if len(l) == 2:# if eqt has "*", then
    return (calc(l[0])*calc(l[1]))
  l = eqt.split("/",maxsplit=1)
  if len(l) == 2:# if eqt has "/", then
    return (calc(l[0])/calc(l[1]))
  return (int(eqt))

def unfold_brackets(eqt): # for example, eqt == "((3+5)*8+2)*2"
  l = eqt.split(')',maxsplit=1)
  if len(l) == 1: # if eqt has no brackets, then
    return calc(eqt)
  else:
    # for example, l == ["((3+5", "*8+2)*2"]
    ll = l[0].rsplit('(',maxsplit=1)
    # ll == ["(","3+5"]
    ll.append(l[1])
    # ll == ["(","3+5","*8+2)*2"]
    ll[1] = str(calc(ll[1]))
    # ll == ["(",8,"*8+2)*2"]
    l="".join(ll)
    # ll == "(8*8+2)*2"
    return unfold_brackets(l)

n=int(input())
datasets=[input() for i in range(n)]
for line in datasets:
  l = line.split("=",maxsplit=1)[0]
  print(unfold_brackets(l))