03-Methods and Functions
03-Methods and Functions
Difficulty of
Problems You
Can Solve
Progress in Python
Complete Python Bootcamp
Difficulty of
Problems You
Can Solve
Basic Data
Types
Progress in Python
Complete Python Bootcamp
Difficulty of
Problems You
Can Solve
Loops and
Logic
Basic Data
Types
Progress in Python
Complete Python Bootcamp
Functions
Difficulty of
Problems You
Can Solve
Loops and
Logic
Basic Data
Types
Progress in Python
Complete Python Bootcamp
def name_of_function():
Keyword telling
Python this is a
function.
Complete Python Bootcamp
def name_of_function():
def name_of_function():
def name_of_function():
def name_of_function():
def name_of_function():
’’’
Docstring explains
function.
’’’
def name_of_function():
’’’
Docstring explains
function.
’’’
Note: Everything
inside the function is
indented
Complete Python Bootcamp
def name_of_function():
’’’
Docstring explains
function.
’’’
Code then goes inside
the function.
print(“Hello”)
Complete Python Bootcamp
def name_of_function():
’’’
Docstring explains
function.
’’’
print(“Hello”)
Function can then be
executed/called to
see the result.
>> name_of_function()
Complete Python Bootcamp
def name_of_function():
’’’
Docstring explains
function.
’’’
print(“Hello”)
Resulting Output
>> name_of_function()
Complete Python Bootcamp
def name_of_function(name):
’’’
Docstring explains function.
’’’
print(“Hello
”+name)
Functions can accept
arguments to be
>> name_of_function(“Jose”) passed by the user.
Complete Python Bootcamp
def name_of_function(name):
’’’
Docstring explains function.
’’’
print(“Hello
”+name)
Functions can accept
arguments to be
>> name_of_function(“Jose”) passed by the user.
Complete Python Bootcamp
def add_function(num1,num2):
return
num1+num2
Return allows to save
the result to a
>>
>> print(result)
>> 3
Complete Python Bootcamp
def add_function(num1,num2):
return
num1+num2
Most functions will
use return. Rarely will
>>
>> print(result)
>> 3
Complete Python Bootcamp