Created
October 7, 2015 15:26
-
-
Save oten/93614bdb539a0f152731 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
sw = {'+': lambda a, b: a + b, | |
'-': lambda a, b: a - b, | |
'*': lambda a, b: a * b, | |
'/': lambda a, b: a / b} | |
from sys import argv | |
if len(argv) != 4: | |
print( | |
"""Usage: | |
{0} num_1 op num_2 | |
Ex.: | |
{0} 2 + 2 | |
4.0""".format(argv[0])) | |
exit(-1) | |
num_1, op, num_2 = argv[1:] | |
num_1 = float(num_1) | |
num_2 = float(num_2) | |
print(sw[op](num_1, num_2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment