Title: Inexperienced Formula

Dr.: Peter, I've finally done it.
Peter: Again? What kind of pointless invention is it this time?
Dr.: I've come up with a groundbreaking method to process formulas using a computer. Take a look at this table.

[Table showing normal notation and the "groundbreaking" notation]

Peter: Uh-huh.
Dr.: That alone won't make any sense to an inexperienced person like you. The crucial part starts here.
Peter: Or rather...
Dr.: You know that computers have a data structure called a stack, right? It's that "last in, first out" thing.
Peter: Yes, I know, but...
Dr.: This groundbreaking notation uses that stack. For example, with "10 2 12 - /", it's processed as follows.

[Table showing the processing steps]

Dr.: See? No need to worry about parentheses or operator precedence, right? The word order becomes "divide by the result of subtracting 2 from 10." It's somewhat similar to the language of his far eastern island country, Japanese.
With this groundbreaking invention, our research lab will be secure. Haha.
Peter: Actually, Doctor, when I was in Japan, we learned this in the basic course at Aizu University. They called it "Reverse Polish Notation," and everyone programmed with it easily.
Dr.: ...

So, instead of Peter, the Doctor has decided to teach this program. Please create a program that takes a formula written in Reverse Polish Notation as input and outputs the result.

Input:
Multiple datasets are given. Each dataset consists of a formula in Reverse Polish Notation (a string of up to 80 characters with integers and single-character operators separated by a space). Formulas that involve dividing a value by 0 or a value very close to 0 will not be given. The number of datasets does not exceed 50.

Output:
For each dataset, output the calculated result (real number) on a single line. The result may contain an error of up to 0.00001.

Sample Input:
10 2 12 - /
3 4 - 7 2 3 * + *
-1 -2 3 + +

Output for the Sample Input:
-1.000000
-13.000000
0.000000

# Buggy version:
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.div }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(float(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print('{:.6f}'.format(stack[0]))
        

# Fixed version:
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element in func:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
        else:
            stack.append(float(element))
    print('{:.6f}'.format(stack[0]))

# Buggy version:
def is_float_str(num_str, default=0):
    try:
        return {"is_float": True, "val": float(num_str)}
    except ValueError:
        return {"is_float": False, "val": default}


def compute(operand, val1, val2):
    if operand == "+":
        return val1 + val2
    elif operand == "-":
        return val1 - val2
    elif operand == "*":
        return val1 * val2
    elif operand == "/":
        return val1 / val2


def get_input():
    while True:
        try:
            yield input()
        except EOFError:
            break


# split with ' '
formulas = list(get_input())
for (i, formula) in enumerate(formulas, 0):
    formulas[i] = formula.split(' ')
stack = []

for formula in formulas:
    stack = []
    for elm in formula:
        if is_float_str(elm)["is_float"]:
            stack.append(is_float_str(elm)["val"])
        elif elm in ['+', '-', '*', '/']:
            stack.append(compute(elm, stack.pop(), stack.pop()))
    if len(stack) == 1:
        print(str(stack[0]))



# Fixed version:
def is_float_str(num_str, default=0):
    try:
        return {"is_float": True, "val": float(num_str)}
    except ValueError:
        return {"is_float": False, "val": default}


def compute(operand, val1, val2):
    if operand == "+":
        return val2 + val1
    elif operand == "-":
        return val2 - val1
    elif operand == "*":
        return val2 * val1
    elif operand == "/":
        return val2 / val1


def get_input():
    while True:
        try:
            yield input()
        except EOFError:
            break


if __name__ == '__main__':
    # split with ' '
    formulas = list(get_input())
    for (i, formula) in enumerate(formulas, 0):
        formulas[i] = formula.split(' ')
    stack = []

    for formula in formulas:
        stack = []
        for elm in formula:
            if is_float_str(elm)["is_float"]:
                stack.append(is_float_str(elm)["val"])
            elif elm in ['+', '-', '*', '/']:
                stack.append(compute(elm, stack.pop(), stack.pop()))
        if len(stack) == 1:
            print(format(stack[0], '.6f'))