0% found this document useful (0 votes)
17 views6 pages

Chapter 3 Class Notes

Uploaded by

sharad9shashwat
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)
17 views6 pages

Chapter 3 Class Notes

Uploaded by

sharad9shashwat
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/ 6

GD GOENKA INTERNATIONAL SCHOOL

NOIDA EXTENSION
CLASS 12
COMPUTER SCIENCE
CHAPTER 3. FUNCTIONS

1. Function is a collection of statements which is made to perform a


specific task.
2. To execute a function, we have to call it in the program.
3. Instead of writing a large program, we can write small functions as a
specific part of program to accomplish the task.
4. Once written a function can also be used in other programs as library
functions.
5. Functions can be categorized in three types:
a. Built- in
b. Modules
c. User Defined
Built- In Functions:
i. Type Conversion Functions: The functions which
converts the values from one type to another line int (),
str (), float ().
ii. Input Function: It is used to take input from user in the
form of string.
Example: x= input (‘Enter your name:’)
iii. eval Function: It is used to evaluate the value of a string.
Example: x= eval (‘55+10’)
print (x) (Output: 55)
iv. min Function: It returns the smallest value among given
list of values.
v. max Function: It returns the biggest value among given
list of values.
vi. abs Function: It returns the absolute value of any integer
which is always positive.
vii. type Function: Used to identify the type of any value or
variable.
viii. round Function: Returns the rounded number of given
number up to given position.
ix. len Function: Returns the length of given string.
x. round Function: Returns the rounded number of given
number up to given position.
xi. range Function: Used for loop. Range (start, stop, step)
User Defined functions: We use def keyword to prepare a user
defined function.
def Function_name (List of Parameters):
‘docstring’
Statement (s)
Parameters and Arguments in Functions:
• When we write header of any function then the one or more values
given to its parenthesis () are known as parameter.
• These are the values which are used by the function for any specific task.
• While argument is the value passed at the time of calling a function.
• In other words, the arguments are used to invoke a function.
• Formal parameters are said to be parameters and actual parameters are
said to be arguments.
Scope of Variable:

• Scope of variable means the part of program where the variable will be
visible. It means where we can use this variable.
• We can say that scope is the collection of variables and their values.
• Scope can be of two types:
▪ Global (Module): All those names which are assigned at top
level in module or directly assigned in interpreter.
▪ Local (Function): Those variables which are assigned within
a loop of function.
Flow of execution at the time of function call:
• The execution of any program starts from the very first line and this
execution goes line by line.
• One statement is executed at a time.
• Function doesn’t change the flow of any program.
• Statements of function doesn’t start executing until it is called.
• When function is called then the control is jumped into the body of
function.
• Then all the statements of the function get executed from top to bottom
one by one.
• And again, the control returns to the place where it was called.
• And in this sequence the python program gets executed.

You might also like