2. Functions def
¶
We learned some Python functions:
len
,int
,float
,print
, andinput
.Now we will create our own functions.
I use
def
to define the function andreturn
to return a value.There are functions that do not return anything.
This function returns
True
if the parameterx
is even,False
otherwise.Note that, unlike what we have seen so far, these lines of code will not be executed immediately.
It is necessary to call the function to execute them.
You have attempted of activities on this page