Methods and Functions

Python Built-in Functions

The built-in Python functions are pre-defined by the python interpreter. There are 68 built-in python functions. These functions perform a specific task and can be used in any program, depending on the requirement of the user.

python functions

Source Code

What are Python Functions?

There are three types of functions in the python programming language. These are:

The pre-defined built-in function of the python programming language is given below:

Python abs()

this function is used to generate the absolute value of a number

Python all()

This python returns true when all the elements in iterable are true

Python any()

This method is used to check if any Element of an Iterable is True

Python ascii()

Returns String Containing Printable Representation

Python bin()

this function is used to convert an integer to the equal binary string

Python bool()

Converts the given Value to Boolean

Python bytearray()

the method is used to return an array of given byte size

Python bytes()

the method is used to return an immutable bytes object

Python callable()

this method checks if the Object is Callable

Python chr()

From an Integer, this function returns a Character (a string).

Python classmethod()

for a given function, returns the class method

Python compile()

This method returns a Python code object.

Python complex()

Creates a Complex Number

Python delattr()

Removes an attribute from an object.

Python dict()

Creates a Dictionary

Python dir()

Tries to Return Attributes of Object

Python divmod()

Returns a Quotient and Remainder Tuple.

Python enumerate()

Returns an Enumerate Object

Python eval()

Runs Python Code Within Program

Python exec()

Executes a Program That Was Created Dynamically

Python filter()

constructs iterator from true elements

Python float()

returns floating-point number from number, string

Python format()

returns a formatted representation of a value

Python frozenset()

returns immutable frozenset object

Python getattr()

returns the value of an object’s named attribute

Python globals()

returns dictionary of the current global symbol table

Python hasattr()

returns whether the object has a named attribute

Python hash()

returns hash value of an object

Python help()

Invokes the built-in Help System

Python hex()

Converts to Integer to Hexadecimal

Python id()

Returns Identify of an Object

Python input()

reads and returns a line of string

Python int()

from a number or string, returns an integer

Python isinstance()

Checks if an Object is an Instance of Class

Python issubclass()

Checks if a Class is Subclass of another Class

Python iter()

returns an iterator

Python len()

Returns Length of an Object

Python list()

creates a list in Python

Python locals()

The dictionary of a current local symbol table is returned.

Python map()

Applies Function and Returns a List

Python max()

returns the largest item

Python memoryview()

returns an argument’s memory view

Python min()

returns the smallest value

Python next()

Retrieves next item from the iterator

Python object()

creates a featureless object

Python oct()

returns an integer’s octal representation

Python open()

Returns a file object

Python ord()

returns an integer of the Unicode character

Python pow()

returns the power of a number

Python print()

Prints the Given Object

Python property()

returns the property attribute

Python range()

between start and stop, return a sequence of numbers

Python repr()

returns the object’s printed representation

Python reversed()

returns the sequence’s reversed iterator

Python round()

rounds a number to specified decimals

Python set()

constructs and returns a set

Python setattr()

sets the value of an attribute of an object

Python slice()

returns a slice object

Python sorted()

from the specified iterable, returns a sorted list

Python staticmethod()

transforms a method into a static method

Python str()

returns the string version of the object

Python sum()

Adds items of an Iterable

Python super()

Returns a proxy object of the base class

Python tuple()

Returns a tuple

Python type()

Returns the type of the object

Python vars()

Returns the __dict__ attribute

Python zip()

Returns an iterator of tuples

Python __import__()

A function called by the import statement 

How many Functions are in Python?

There are three types of functions in the python programming language. These are:

  1. Built-in functions- There are 68 built-in functions in the Python programming language.
  2. User-defined functions-  To define a user-defined function, the def keyword is used  
  3. Anonymous functions- these are also known as lambda functions. 

What is a Function in Python for example?

A function is a collection of related statements that performs a specific task. To define a function, the def keyword is used. 

Here is the syntax for the function in Python:


def function_name(parameters):






    return [expr]

What is a Function Statement in Python?

A function is a code block that only executes when it is invoked by the user.

To define a function in python, the def keyword is used. 

For example:


def function1():

  print("Hello from the other side")

How to Call a Function in Python

To call a function in Python, the user needs to write the name of the function followed by the parenthesis. 



def function1():

  print("Hello from the other side")


Share with friends

Customize your course in 30 seconds

Which class are you in?
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
Ashhar Firdausi
IIT Roorkee
Dr. Nazma Shaik
Gaurav Tiwari
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.