Created
September 25, 2019 08:52
-
-
Save stefanpejcic/ba1077f69bbb806d3fcbe4fcb75aa7fe to your computer and use it in GitHub Desktop.
Simple calculator with the operator instead of if
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
ops = { | |
"+": operator.add, | |
"-": operator.sub, | |
"/": operator.truediv, | |
"*": operator.mul, | |
"**": pow | |
} | |
print(ops['-'](50, 25)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment