0% found this document useful (0 votes)
13 views2 pages

Functions1 Introduction

Large programs are difficult to manage, so they are broken into smaller units called functions. Functions contain grouped statements that perform coherent tasks. Dividing a program into functions has benefits like quick processing, manageability, and shorter module lengths. Functions can be given names and are self-contained blocks that integrate to solve the original problem, using a divide and conquer approach. There are different types of functions, including built-in functions that are always available, module functions only available when a module is imported, and user-defined functions created by a programmer.

Uploaded by

ADITIYA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Functions1 Introduction

Large programs are difficult to manage, so they are broken into smaller units called functions. Functions contain grouped statements that perform coherent tasks. Dividing a program into functions has benefits like quick processing, manageability, and shorter module lengths. Functions can be given names and are self-contained blocks that integrate to solve the original problem, using a divide and conquer approach. There are different types of functions, including built-in functions that are always available, module functions only available when a module is imported, and user-defined functions created by a programmer.

Uploaded by

ADITIYA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FUNCTIONS

1. Large programs are generally avoided because it is difficult to manage a


single list of instructions .
2. Thus large program is broken into smaller units.These units are called
Functions.
3. Various implications pops up after dividing a program into units. i.e
• Quick processing
• Manageable
• Short length of each module
• Time managing and many more points which we will be discussing
later on
4. A Function can be given a name and it contains a group of program
statements.
5. Functions are self contained block of statements that performs coherent
task of some kind.

Let us take an example to illustrate it.


Type1:(This program is long having lot of statements)
S1
S2
S3
S4
S5
S6
S7
S8
S9
Type 2:(A task has been divided into smaller task and has been allotted to
different function)
Function1 Function2 Function3
S1 s4 s7
S2 s5 s8
S3 s6 s9
That is in type 2:
Function1 is having three statements
Function2 is having three statements
Function3 is having 3 statement.

The example of type2 given above illustrate that there are three
Functions(1,2,3,) having there own self contained block of statements
performing different functionalities.

This approach(type2) of problem solving is called stepwise refinement


method or modular approach or divide and conquer approach.

Divide and conquer approach means that a problem is divided into various
sub problem(as seen in type 2), solutions of various sub problems can be
integrated to form the solution of original problem.

6. There are many functions and each of the functions has been categorized in
three groups.
Types are:
a. Built-in
These are the predefined functions and are always available for use.
For e.g., len(),type(),int(),input() etc.
b. Modules
These functions are predefined in a particular modules and can only be
used when that module is imported.
For e.g., Maths function(like sin(),cos() etc.) can only be used when we
import math module in our code.
c. User defined
These are defined by programs. In order to create these category of
functions programmer can decide the name of their choice (considering
naming rule of identifier) for the function and functionality of function
are decided by the programmer.

You might also like