Not Exactly Sure How Functions Work


#1

Hey There

Thank you for taking the time firstly to those who can answer my questions. Can someone give a simplified summary of how a function works and also what the "def" does? I took a break from coding and now i struggling to get keep learning.

Thanks A Lot!


#2

def is simply to tell Python that you are making a function. So you make a function like this,

def function_name( some_parameters ): #parameters are temporary variables that are defined when you call the function, and only work within it.
    #Your code goes here
    return true  #return ends the function, but can also return a value, in this case true
#Then to call the function,
function_name( the_parameters_you_want_to_give_the_function )