Created
July 12, 2017 14:56
-
-
Save anonymous/d459c94757cbac5f619ce1061f58099e to your computer and use it in GitHub Desktop.
getopt3 created by britodfbr - https://repl.it/JYcz/1
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) | |
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