Skip to content

Instantly share code, notes, and snippets.

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