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

Functions in Python

Functions in Python are blocks of code that perform specific tasks on passed in data. There are three types of functions in Python: built-in functions like print() and input() that can be used without importing libraries, module defined functions that must be imported from libraries first before using, and user defined functions that are created by programmers using the def keyword to define their functionality.

Uploaded by

Vijay Rawat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views

Functions in Python

Functions in Python are blocks of code that perform specific tasks on passed in data. There are three types of functions in Python: built-in functions like print() and input() that can be used without importing libraries, module defined functions that must be imported from libraries first before using, and user defined functions that are created by programmers using the def keyword to define their functionality.

Uploaded by

Vijay Rawat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Functions in Python

Functions are a block of code which can perform a


specific the task over the data passed into it.
The function in python can also be said as subprogram.
The function can provide the high degree of code
reusing.
In Python, we have 3 types of functions:-
1. Built-in
2. Module defined
3. User defined

Built In functions
Built In functions in python are the functions which can
be used while writing the code/program without
importing any library.
Ex print() , input() , list() , tuple() etc.

Module defined functions


To use Module defined functions, programmer need to
import a specific library in python environment and use
the functions present in it.
Ex

Using dot (.) operator we can access see the list of


functions present in the module.

User defined functions


User defined are those functions which are defined by
the programmer i.e. their functionality is defined by
the programmer.
These are created using “ def ” keyword the def stands
for definition.
Example :
Syntax:

Practice questions:-
Q1 Import math module and use any one function.
Q2 Import random module and use any one function.
Q3 Create a user defined function calculating sum,
cube, square using below example.

You might also like