Skip to content

Instantly share code, notes, and snippets.

@technillogue
technillogue / calc.py
Created June 28, 2013 18:53
A more complicated recursive python calculator
from collections import OrderedDict
#reverse order of operations
#I didn't have to use an OrderedDict, but it's cute
operations = OrderedDict([
("+", lambda x, y: x + y),
("-", lambda x, y: x - y),
("/", lambda x, y: x / y),
("*", lambda x, y: x * y),
("^", lambda x, y: x ^ y)