Mastery12 – Creating python functions

Creating a function in python is not hard, give it a name and give it a job.

to create it first we need to define it, giving it a name and a number of variables it needs.

def  adding_function(a,b):

and inside the function the operation it will perform, this function will add a + b and return the result.

def  adding_function(a,b)

       return a+b

now call the function to add two numbers.

reference:

http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_2.6/Defining_Functions

CC BY 4.0 Mastery12 – Creating python functions by sergio is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.