Linux Programming (Python)-Part 3 – Functions and Modules

Function is a built-in program that available in Python that we can use to simplify our programming code. Mostly every programming language provide their built-in function according to purpose why it’s created. Functions in C, python, pearl, vb, assembly will be different.

To use function in python, you have to write the function name then followed by the parameters that the function need. Parameter is the information that will be used by function to solve the problem.

Although you have imported the module but python still can’t recognize the function. It’s happen because python doesn’t know which module this function come from. You have to tell python. Type the module followed by the function name (module.function).

>>> math.floor(10.57)
10.0
>>>

Another sample, square root of 81.>>> math.sqrt(81)
9.0
>>>

This function call also be assigned to a variable. It’s useful because you don’t have to remember the module and function name everytime.