Created
January 23, 2021 15:23
-
-
Save agusrichard/b7bda4dbcd48fbfbd0ef5db58e113db0 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
# Simple calculator function with limited funcionalities | |
def simple_calculator(operation): | |
"""Returns operation we want, either add, subtract, multiply or divide""" | |
def add(x, y): | |
return x + y | |
def subtract(x, y): | |
return x - y | |
def multiply(x, y): | |
return x * y | |
def divide(x, y): | |
return x / y | |
if operation == "add": | |
return add | |
elif operation == "subtract": | |
return subtract | |
elif operation == "multiply": | |
return multiply | |
elif operation == "divide": | |
return divide | |
else: | |
raise Exception("Must be either add, subtract, multiply, or divide") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment