#39213: python eval()


mu0975353917@gmail.com (Moon Chan)

學校 : 國立雲林科技大學
編號 : 188583
來源 : [36.235.71.91]
最後登入時間 :
2024-04-28 23:39:27
f698. 後序運算式求值 -- 板橋高中教學題 | From: [123.192.202.177] | 發表日期 : 2024-01-23 21:49

a = list(input().split())

number = []

while (a != []):

    op_or_int = a.pop(0)

    try:  # int

        eval(op_or_int)

        number.append(op_or_int)

    except:  # op

        count = number.pop()

        count1 = number.pop()

        number.append(str(eval(count1+op_or_int+count)))

 

print(format(float(number[0]),".0f"))

 
ZeroJudge Forum