Homebreadcumb forward arrow iconBlogbreadcumb forward arrow iconData Sciencebreadcumb forward arrow iconPython In-Built Function [With Syntax and Examples]

Python In-Built Function [With Syntax and Examples]

Last updated:
28th Nov, 2021
Read Time
11 Mins
share image icon
In this article
Chevron in toc
View All
Python In-Built Function [With Syntax and Examples]

Built-in functions in Python are defined as those types of functions that are pre-defined in Python. The programming language Python offers several functions for performing a wide variety of tasks. Those functions which are already present in the Python interpreter are known as the built-in functions. Lots of built-in functions are available in Python. A few of the built-in functions are hash(), filter(), int(), print(), set()

built-in functions in Python

built-in functions in Python along with its examples. 

1. abs function()

Using the abs() function in Python is used for returning the absolute value of a given number. The function takes only one argument: the function’s number to return its absolute value. This argument can be of any type, such as an integer or a floating point. If, supposedly, the argument is a complex number, then the function will return the magnitude of the complex number. 

An example of the Python abs() is shown below:


The output of the program will be:

Learn data science course from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.

2. all() function

This is another type of built-in function in Python. The function all() accepts an iterable object. Such iterable objects might be a dictionary, list, etc. Using the function all() returns the value of either true or false. If all the elements are valid in the iterable, the function returns true. Else, the function returns false. 

An example of the all() function in Python is shown below.

upGrad’s Exclusive Data Science Webinar for you –

3. bin() function in Python

Python’s bin() function is used for any specified integer to return that integer’s binary representation. The results of the function always have the prefix 0b. 

An example of the function bin() in Python is shown below.


4. bool() in Python

This is another type of built-in function in Python. As the function’s name goes, the function converts any value to the Boolean form that means true or false. This is done through the use of the standard procedure of truth testing.

An example of the function is shown below.

The output of the program is shown below.


Our learners also read: Top Python Free Courses

5. bytes() in Python

The function bytes() is used in Python for returning an object of byte. The function is immutable compared to the bytearray() function in Python. Empty bytes are created for an object of a specified size.

An example of the Python bytes() function I showed below.


Explore our Popular Data Science Certifications

6. Callable() function in Python

The callable() function, as the name specifies, can be called in the Python program. The function’s task is to check and then return the true value if the object passed through the function is callable. Else, the function returns the value of false. 

An example of the callable() function in Python is

x = 8  


The output of the program is False.

7. Compile() function 

The function compiles()in Python uses the input as source code and then returns an object of the code, which can be executed later through the function exec(). 

The compile() function in Python can be used as shown below.

8. Exec() function

The function exec() in Python is used for executing the Python program dynamically. It can be an object or a string, and the function accepts large segments of code compared to the function eval(), which accepts only a single expression. 

9. Sum() function

 Python’s sum() function is used for getting the sum of numbers from an iterable source such as a list. 

10. Any() function in Python

If any item turns out to be true in the iterable, the function any() returns true. Else, the function returns false. 

Top Data Science Skills to Learn

11. Ascii() function in Python()

This is another type of built-in function in Python. It returns a string that contains object representation and then escapes the characters in the string, which are non-ASCII using \u, \U, or \x escapes.

12. Bytearray() in Python

The function bytearray() in Python returns an object of bytearray and can also carry out conversion of objects into byte arrays. It is also able to create an object of byte array of any specific size which is empty. 

13. Eval() function in Python

The function eval() in Python performs the task of parsing the expression passed on to it. The function also runs the expression(code) in Python that is present within the code. 

14. Float function in Python

The built-in function float() in Python returns a floating-point number from a string or a number. 

An example of the float() function in Python is shown below.

15. globals() function in Python

The function globals() in Python returns a dictionary for the current global symbol table. The term Symbol table means a type of data structure that stores all the information necessary for the program. The symbol table includes the names of variables, classes, methods, etc.  

16. iter() function in Python

If the program has to return an object of the type iterator, then Python’s function iter() can be used. The function leads to creating an object that one element can iterate at a time. 

An example of the function iter() is shown below.

The output of the program is 






17. locals() function in Python

The built-in function of Python i.e., locals() is used to return a local symbol table dictionary. It is also used for the modification of the dictionary.

An example of the locals() function in Python is shown below.

18. Chr() function in Python

The function chr() is used in Python to achieve a string representing a character that further points to an integer of Unicode code. If the user uses the function chr(97), the function will return a string “a”. The function will throw an error taking an argument of the integer type that exceeds the range specified. Usually, the standard range that is specified in the argument ranges from 0-1,114,111.

An example of code using the chr() function in Python is shown below.


19. Complex() function in Python

This built-in function in Python is used for the conversion of numbers into a complex number. The function complex() is also able to convert the strings into a complex number. The first parameter is the real parts, and the second parameter is the imaginary parts.

20. delattr() function in Python

If the user wants to delete any attribute from a specified class in Python, the function delattr() can be used. The function takes two parameters. The first parameter taken is an object from the class, and the second parameter taken is the attribute that needs to be deleted. Once an attribute gets deleted, there is no more presence of the attribute in the class. After deletion of the attribute, if the attribute is tried to be called through the object of the class, then the program throws an error. 

An example of code showing the use of the function delattr() in Python is shown below.


21. dir() function in Python

For returning a list of the names in the local scope, the function dir() is used in Python. 

22. divmod() function in Python

In Python, the function divmod() is used for getting the quotient and the remainder of two numbers. The function takes two arguments in the numeric form, and a tuple is returned. For proper functioning, the function should have both arguments and it should be numeric. 

23. dict() function in Python

The function dict() in Python acts as a constructor that leads to creating a dictionary. The Python dictionary provides three different types of constructors for creating a dictionary. 

  • An empty dictionary is created when no arguments are passed.
  • The same pair of key-value dictionaries are created when positional arguments are used.
  • In case of the keyword arguments, the arguments of the keyword and the values are further added to the created dictionary from positional arguments.

Read our popular Data Science Articles


Apart from the above-mentioned built-in functions, Python has many other built-in functions specially designed to perform special functions. If you want to know more about the Python built-in functions and want to have practical knowledge of the programming language, check the Online Data Science Program offered by upGrad. The certificate course is provided in association with the IIIT Bangalore. Further details of the course can be explored on our website. Also, if any assistance is required, our team may be contacted for help.

Check out The Trending Python Tutorial Concepts in 2024


Rohit Sharma

Blog Author
Rohit Sharma is the Program Director for the UpGrad-IIIT Bangalore, PG Diploma Data Analytics Program.

Frequently Asked Questions (FAQs)

1What does the built-in function in Python mean?

The built-in functions in Python are predefined functions in Python.

2What do the built-in abs() function do?

The function helps in returning the absolute value for any given number.

3In Python, how many built-in functions are present?

There are around 69 built-in functions in Python.

Explore Free Courses

Suggested Blogs

Data Mining Techniques & Tools: Types of Data, Methods, Applications [With Examples]
Why data mining techniques are important like never before? Businesses these days are collecting data at a very striking rate. The sources of this eno
Read More

by Rohit Sharma

07 Jul 2024

An Overview of Association Rule Mining & its Applications
Association Rule Mining in data mining, as the name suggests, involves discovering relationships between seemingly independent relational databases or
Read More

by Abhinav Rai

07 Jul 2024

What is Decision Tree in Data Mining? Types, Real World Examples & Applications
Introduction to Data Mining In its raw form, data requires efficient processing to transform into valuable information. Predicting outcomes hinges on
Read More

by Rohit Sharma

04 Jul 2024

6 Phases of Data Analytics Lifecycle Every Data Analyst Should Know About
What is a Data Analytics Lifecycle? Data is crucial in today’s digital world. As it gets created, consumed, tested, processed, and reused, data goes
Read More

by Rohit Sharma

04 Jul 2024

Most Common Binary Tree Interview Questions & Answers [For Freshers & Experienced]
Introduction Data structures are one of the most fundamental concepts in object-oriented programming. To explain it simply, a data structure is a par
Read More

by Rohit Sharma

03 Jul 2024

Data Science Vs Data Analytics: Difference Between Data Science and Data Analytics
Summary: In this article, you will learn, Difference between Data Science and Data Analytics Job roles Skills Career perspectives Which one is right
Read More

by Rohit Sharma

02 Jul 2024

Graphs in Data Structure: Types, Storing & Traversal
In my experience with Data Science, I’ve found that choosing the right data structure is crucial for organizing information effectively. Graphs
Read More

by Rohit Sharma

01 Jul 2024

Python Banking Project [With Source Code] in 2024
The banking sector has many applications for programming and IT solutions. If you’re interested in working on a project for the banking sector,
Read More

by Rohit Sharma

25 Jun 2024

Linear Search vs Binary Search: Difference Between Linear Search & Binary Search
In my journey through data structures, I’ve navigated the nuances of linear search vs binary search in data structure, especially when dealing w
Read More

by Rohit Sharma

23 Jun 2024

Want to build a career in Data Science?Download Career Growth Report
footer sticky close icon