...

/

Storing Function Reference in a Variable

Storing Function Reference in a Variable

Learn how to store the reference to a function in a variable. Also, observe how functions are treated as objects in Python.

Variable vs. function initialization and usage

When you look at the way a variable is initialized and used in Python and compare it to the way a function is declared and used, you might easily assume that variables and functions are completely different things.

Press + to interact
a = 10
def square(x):
return x*x
b = square(a)
print(a)
print(b) # prints 100

Looking at the code, ...