Review
What are the different parts of a function called
Positional, Keywork, Display
What is the difference between a Positional Argument and a Keyword Argument?
```python
def display_square(x, message):
print(message, x*x)
~~~
(1) Positional Arguments must be the same order as parameters:
Call function:display_square(5, 'Square of 5')
(2) Keyword Arguments are “wordy” but can be in different order:
Call Function: display_square(message = 'Square of 5', x = 5)
Positional, Keywork, Default
What are default values?
(3) Default Value used when the argument is missing from the call
```python
def display_square(x, message = “The solution is”):
#Message arugment is default equal to ‘The solution is’
#If the function is called without an argument, default is used
print(message, x*x)
> > > display_square(5)
The soluation is 25
~~~
What happens when a function defintiion is called?
When a function definition is executed:
How are functions “callable?”
Function objects are callable, they can use the invocation operator () to execute the code
Note: Difference between …
my_function: a variable references a function objectmy_fuction(1, 2): a call to the function object, evaluates whatever it returnsHow can functions be used as variables?
Note: Difference between …
my_function: a variable references a function objectmy_fuction(1, 2): a call to the function object, evaluates whatever it returnsFunctions as variables: can be assigned to another variable
How can functions be used as arguments?
Note: Difference between …
my_function: a variable references a function objectmy_fuction(1, 2): a call to the function object, evaluates whatever it returnsFunctions as arguments: can be passed as arguments to another function
How can functions be a return type?
Functions as return types: can be returned from a function