Python Functions
From
Python Coding Made Simple
(Part III)
By
Femi Mike Okegbola
Email:
1
, Content
#Pythoncoding
#Functions
#Returnstatements
#Comments
Functions
In programming, function is a combination of codes which are written to perform a
specific task. This is administered by calling a function that houses certain coding lines,
which have been generated to carry out a given task. This is initiated by introducing a key
word called def, and the succeeding word after this key word is the function name. In
this note, a number of functions have been written for different purposes ranging
from writing a hello message for the user, to generating exponential values.
________________________________________________________________________
def hello_message ():
print ("Hello World")
hello_message ()
________________________________________________________________________
OUTPUT
Hello World
A function can be made to pass parameters. This is illustrated below. The line
preceded by the ‘#’ is a comment that gives a hint on the program. It is a practice in
Python programming, and usually the console ignores any line within the code that is
preceded by the ‘#’.
2
From
Python Coding Made Simple
(Part III)
By
Femi Mike Okegbola
Email:
1
, Content
#Pythoncoding
#Functions
#Returnstatements
#Comments
Functions
In programming, function is a combination of codes which are written to perform a
specific task. This is administered by calling a function that houses certain coding lines,
which have been generated to carry out a given task. This is initiated by introducing a key
word called def, and the succeeding word after this key word is the function name. In
this note, a number of functions have been written for different purposes ranging
from writing a hello message for the user, to generating exponential values.
________________________________________________________________________
def hello_message ():
print ("Hello World")
hello_message ()
________________________________________________________________________
OUTPUT
Hello World
A function can be made to pass parameters. This is illustrated below. The line
preceded by the ‘#’ is a comment that gives a hint on the program. It is a practice in
Python programming, and usually the console ignores any line within the code that is
preceded by the ‘#’.
2