Created
July 12, 2017 14:58
-
-
Save anonymous/182a9264fc8b224fde3522451396293e to your computer and use it in GitHub Desktop.
getopt2 created by britodfbr - https://repl.it/JYbi/7
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
def calc(x,y,op): | |
try: | |
x, y = int(x), int(y) | |
return{ | |
'+': x + y, | |
'-': x - y, | |
'*': x * y, | |
'/': x // y, | |
'%': x % y, | |
}.get(op,'Error') | |
except: | |
raise | |
print(calc(5,2,'+')) | |
print(calc(5,2,'-')) | |
print(calc(5,2,'*')) | |
print(calc(5,2,'/')) | |
print(calc(5,2,'%')) | |
print(calc(5,2, 'a')) | |
print(calc(5,2, '**')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment