Skip to content

Instantly share code, notes, and snippets.

@enseitankad0
Created March 1, 2018 22:11
Show Gist options
  • Save enseitankad0/b781796c295b49f40f316c8d1e22f11e to your computer and use it in GitHub Desktop.
Save enseitankad0/b781796c295b49f40f316c8d1e22f11e to your computer and use it in GitHub Desktop.
Functions
##### FUNCTIONS IN PYTHON ###
def returning(a):
return "I am a result!",a
returnedVal = returning(5)
print(returnedVal) ## need to extract from brackets
def add(a,b=4,d=10):
c = a + b + d
return c
result1=add(10)
print(result1)
### SCOPE ###
def outer(a):
def nested(x):
return x*a;
a = nested(a)
return a
print(outer(5)) ##5*5
def f(a):
def g(b):
return a*b;
return g
print(f(4)(24))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment