#!/usr/bin/env python # -*- coding: utf-8 -*- # rpn.py # 逆ポーランド記法を使った電卓プログラム import string stack = [] while 1: x = raw_input('? ') if x == '+': stack.append(stack.pop() + stack.pop()) elif x == '-': stack.append(stack.pop(-2) - stack.pop()) elif x == '*': stack.append(stack.pop() * stack.pop()) elif x == '/': stack.append(stack.pop(-2) / stack.pop()) else: stack.append(string.atof(x)) print stack,