Page 52 - Modular v1.1 Pyhton
P. 52
05 FUNCTIONS IN
PYTHON
Your Aim
to learn about:
Features of Function Components of Python Function
Advantages of Functions Types of Functions in Python
Creating a Function Calling a Function
Some More Programs
A function is a block of organised and reusable code used to perform a single or related action.
Functions receive data in the form of arguments and use it to run a specified set of statements
and produce the final output.
FEATURES OF FUNCTION
Some important features of functions are:
A program is divided into small modules and each module performs some specific task. Each
module can be called as per the requirement.
We can call a function as many times as required. This saves the programmer the time and
effort to rewrite the same code again. Therefore, it also reduces the length of the program.
Dividing a bigger program into smaller functions makes the program more manageable. It
makes debugging easy and makes the code efficient, both in terms of time and memory.
COMPONENTS OF PYTHON FUNCTION
A Python function consists of the following components:
Name of the function: A function name should be unique and easy to correlate with the
task it will perform. We can have functions of the same name with different parameters.
Arguments: The input given to the functions are referred to as arguments. A function can or
cannot have any arguments.
Statements: The statements are the executable instructions that the function can perform.
Return Value: A function may or may not return a value.
50 Touchpad MODULAR (Version 1.0)

