Creating Functions

--Originally published at Programming Fundaments

To create a function  after you call it, you must set the parameters list, or the arguments, and after you call the function you must use the command return(). For a better explanation here is an example:

def fahrenheit(T_in_celsius):
    """ returns the temperature in degrees Fahrenheit """
    return (T_in_celsius * 9 / 5) + 32

for t in (22.6, 25.8, 27.3, 29.8):
    print(t, ": ", fahrenheit(t))

In this function you are defining the parameters list as T_in_celsius, and defining  the t as a list of numbers, which are you celsius numbers, ands it will be converted in fahrenheit, and you will use the return comand to make it repeat the steps with all of the umbers of the list, as you can observe in the next part:

22.6 :  72.68
25.8 :  78.44
27.3 :  81.14
29.8 :  85.64

And thats how you create a function, as you can see its knda difficult in the beginning but after a couple trials and errors you can master this in no time

More information and examples at: http://www.python-course.eu/python3_functions.php