PLEASE SUBSCRIBE!!!
In the previous lesson ( • Python Programming: Lesson 14 - Funct... ), we continued exploring functions and talked about some more examples. Here, we will say even more about functions and talk more about docstrings. Don't worry, this is a lengthy and important topic but we will cover new content (modules) in the next video! • Python Programming: Lesson 16 - Modules
We know that functions are modular blocks of code that achieve particular tasks. They can accept no inputs, one input, or more than one input. Functions can accept other functions as input.
We know that functions can return values or print values. It turns out that functions can also do both.
def f(x):
print(x+2)
return x+3
u = f(5), prints 7 and assigns u to 8
v = f(9), prints 11 and assigns v to 12
print(u+v), prints 20
Function reference variables are alias names for functions that enable a variable to take on the same operation as an existing function.
def a( x , y ):
return y-1
b = a
print( b(8,15) ) prints 14 on the console
0:30 Review of Functions
2:51 Review of Data Types in Functions
5:08 Review of Functions that Print or Return Values
7:39 Review of Nested Functions
10:21 NEW: Functions that Both Print and Return Values
13:32 NEW: Function Reference Variables
15:37 NEW: Docstrings
We talk about formal Java documentation for our functions in this video: • Java Programming: Lesson 29 - Javadocs
Ready for the next video? • Python Programming: Lesson 16 - Modules (same link as above, module 16)
Thanks for watching, and PLEASE SUBSCRIBE!!!