0% found this document useful (0 votes)
5 views

Lab 3

Uploaded by

vikashskumarb23
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)
5 views

Lab 3

Uploaded by

vikashskumarb23
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/ 7

Lab-3

Aim: To understand and develop problem solving skills using functions and modules in
Python programming.

Software used: Visual Studio Community 2022.

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.

There are two types of functions:-


a) Built-in Function
b) User defined functions

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.

Definition of some built-in function:-


1)max(): The max function will select the maximum of the two arguments of the function.

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]

Code on Built-in functions:-


2
3
4

b) User defined functions:-


User defined functions are defined by the programmer and contain a set of code as per
the requirement of the programmer.
These functions are used to avoid the repeatability of the code.

Code on User defined functions:-


5

\
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.

You might also like