Defining Python Functions

Overview

What is a Function?

Function defintions

# this is outside the scope of the of the function code-block
def my_function_name(): # this is the function signature
    output_value = "Hello world" # this is the beginning of the function code-block
    print(output_value) # this is the ending of the function code-block
# this is outside the scope of the of the function code-block

Function Parameters

# this is outside the scope of the of the function code-block
def my_function_name(input_value): # this is the function signature
    output_value = "Hello " + input_value # this is the beginning of the function code-block
    print(output_value) # this is the ending of the function code-block
    return None # explicit return
# this is outside the scope of the of the function code-block

return

# this is outside the scope of the of the function code-block
def my_function_name(input_value): # this is the function signature
    output_value = "Hello " + input_value # this is the beginning of the function code-block
    return output_value # this is the ending of the function code-block
# this is outside the scope of the of the function code-block

return vs print