Skip to content

Instantly share code, notes, and snippets.

@Abdurahman-hassan
Created June 19, 2022 20:57
Show Gist options
  • Save Abdurahman-hassan/107787b6d78a4ab0b47b73282ea1fcdd to your computer and use it in GitHub Desktop.
Save Abdurahman-hassan/107787b6d78a4ab0b47b73282ea1fcdd to your computer and use it in GitHub Desktop.
simple uses of order functions , that we set a param in a function and then we use this param as a new function that takes the same param of the original function
def add(n1, n2):
return n1 + n2
def multiply(n1, n2):
return n1 * n2
def calc(n1, n2, newFun):
return newFun(n1, n2)
print(calc(5, 4, multiply))
print(calc(5, 4, add))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment