Created
November 2, 2016 07:15
-
-
Save LotusChing/944eadbfef885f54f750c9db358aa3be to your computer and use it in GitHub Desktop.
Case in Python
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
matrix = { | |
'+': lambda x, y: x + y, | |
'-': lambda x, y: x - y, | |
'*': lambda x, y: x * y, | |
'/': lambda x, y: x / y | |
} | |
def compute(x, oper, y): | |
return matrix[oper](x, y) | |
print(compute(1, '*', 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment