Types of Functions in Python Programming

Types of Functions in Python: As we have discussed Functions in detail with examples in our previous article. Now we will discuss Types of Functions in Python. There are two types of Function in Python Programming:

python-video-tutorials

Types of functions

types of functions in python programming

Types of Functions in PythonThere are two types of functions available in python. These are:

  • Built-in Functions or Pre-defined
  • User-defined Functions

1). Built-in Functions:

Built-in functions are the functions that are already written or defined in python. We only need to remember the names of built-in functions and the parameters used in the functions. As these functions are already defined so we do not need to define these functions. Below are some built-in functions of Python.

Built-in Functions used in Python

Function name Description
len() It returns the length of an object/value.
list() It returns a list.
max() It is used to return maximum value from a sequence (list,sets) etc.
min() It is used to return minimum value from a sequence (list,sets) etc.
open() It is used to open a file.
print() It is used to print statement.
str() It is used to return string object/value.
sum() It is used to sum the values inside sequence.
type() It is used to return the type of object.
tuple() It is used to return a tuple.

More built in functions…

Let’s see one example of built-in functions

#In built functions

x = [1,2,3,4,5]
print(len(x))    #it return length of list
print(type(x))   #it return object type

Output:

# 5                                                                                                                             
# <class 'list'>


2). User-Defined Functions

The functions defined by a programmer to reduce the complexity of big problems and to use that function according to their need. This type of functions is called user-defined functions.

Example of user-defined functions:

#Example of user defined function

x = 3
y = 4
def add():
    print(x+y)
    
add()

Output:

# 7

NoteUser-defined functions are used commonly when we build large projects or applications in our upcoming articles. It is good practice to define functions for larger problems so that our code will remain combined.