Lab 3
Lab 3
Aim: To understand and develop problem solving skills using functions and modules in
Python programming.
Theory:-
Function is a sub program which consists of a set of instructions used to perform a specific
task. A large program is divided into basic building blocks called function.
a) Built-in functions:-
These functions are already stored in python.They are always accessible to the programmer
for usage and cannot be modified.
Some of the built-in functions are max(),min(),len(),range(),type(),etc.
Arguments: The variables assigned within the braces of a function are called arguments.
2)min(): The min function will select the minimum of the two arguments of the function.
3)len(): The length function will specify the number of characters contained in a string.
4)range(): The range function will provide a list of numbers in the range. It’s step size can be
varied.
5)round(): The round off function will round off the number according to the rules of
rounding off.
6)chr(): The character function will type-cast the argument into character data type.
7)float(): The float function will type-cast the argument into the float data type.
8)int(): The int function will type-cast the argument into the int data type.
1
9)pow(): The power function will raise the second argument to the power of the first
argument.[a^b]
10)type(): The type function will specify the type of the argument.[str, float, int,...]
11)tuple(): The tuple function will convert the list into tuple data type.
12)print(): The print function will display the output on the screen.
13)input(): The input function is used to take data from the user.[values]
\
6
Conclusion:-
From the above illustrated programs we are able to use and define functions in the
python programming language.We have studied built-in functions as well as user
defined functions in this lab through various programming problems.