What are the different built-in types in Python?

You'll learn about Python Data Types and their uses in this post as we efficiently write Python programs. You will learn about their purpose, syntax, and how to apply them in programs through examples. The language Python requires no introduction. It is highly strong, adaptable, quick, and simple to learn.

One of the languages that continue to expand and gain popularity year after year is Python. Python is an object-oriented, interpreted computer language used for general-purpose programming. This tutorial will teach us about the various data types in the Python programming language.

Built-in Data Types in Python

There are different types of data types in Python. Some built-in Python data types are −

  • Numeric data types − int, float, complex

  • String data types − str

  • Sequence types − list, tuple, range

  • Binary types − bytes, bytearray, memoryview

  • Mapping data type − dict

  • Boolean type − bool

  • Set data types − set, frozenset

Python Numeric Data types

In Python, the numeric data type is used to hold numeric values.

Integers, floating-point, and complex numbers fall under the Python numbers category. They are defined as int, float, and complex classes in Python.

  • int − holds signed integers of non-limited length.

  • float − holds floating decimal points, and it's accurate up to 15 decimal places.

  • complex − holds complex numbers.

Python String Data type

A string is a collection of Unicode symbols. The name for String in Python is str. Single or double quotations are used to represent strings. The use of triple quotes """ or "' to indicate multiple strings is acceptable. Between the quotations, every character is a part of the string.

The only restriction is the machine system's memory resources, which one may use as many characters as they like. In Python programming, deleting or updating a string will result in an error. As a result, the Python programming language does not permit the alteration of strings.

Python Sequence Data types

  • List − The list is a flexible data type only available in Python. It resembles the array in C/C++ in certain ways. However, the list in Python is noteworthy because it can store many sorts of data simultaneously. A list is an ordered collection of information expressed using commas and square brackets ([]). (,).

  • Tuple − The list and a tuple are comparable in many respects. Tuples hold a collection of elements of various data kinds, much like lists do. The tuple's components are separated by commas (,) and parenthesized (). Due to the inability to change the elements' size and value, tuples are read-only data structures.

  • Range − The range() method in Python returns a list of integers that fall inside a specified range. It is most frequently used to iterate over a series of integers using Python loops.

Python Data Binary types

  • bytes − A bytes object results from the bytes() function. It can produce empty byte objects of the desired size or transform items into byte objects. Bytes() and bytearray() return different types of objects: bytes() returns an immutable object, whereas bytearray() returns an alterable object.

  • bytearray − The bytearray object, an array of the specified bytes, is returned by the bytearray() function. A modifiable series of numbers from 0 to x to 256 is provided.

  • memoryview − Python programs may access an object's internal data that implements the buffer protocol using memoryview objects without copying. The byte-oriented data of an object may be read and written directly without copying it using the memoryview() method.

Python Mapping Data type

  • dict − A dictionary in Python is a collection of data items that are stored in an unordered fashion, much like a map. Dictionaries are made up of key-value pairs, as contrast to other data types, which can only contain a single value. Key-value pairs are included in the dictionary to increase its efficiency. A comma "separates each key," whereas each key-value pair in the representation of a dictionary data type is separated by a colon.

Python Boolean Data type

  • bool − True and False are the two pre-built values the boolean type offers. The provided statement's truth or falsity is determined using these values. It's identified by the bool class. Any non-zero integer or the letter "T" can be used to denote truth, while the number "0" or the letter "F" can denote falsehood.

Python Set Data types

  • set − The data type's unordered collection is called a Python Set. It has components that are unique, iterable, and changeable (may change after creation). The order of the items in a set is ambiguous; it can yield the element's modified sequence. Use the built-in method set() to build the set, or give a list of elements enclosed in curly braces and separated by commas. It may include several kinds of values.

  • frozenset − The frozenset() method returns an immutable frozenset object whose initial elements are taken from the supplied iterable. A frozen set is an immutable version of a Python set object. The elements of a set can be altered at any time, but once a frozen set has been created, its elements cannot be altered.


In this session, we examined Python's data types. In more detail, we looked at two of these data types, None and Numeric. As we have seen, there are four different forms of numeric data: integers, floats, booleans, and complex numbers. We had a birds-eye perspective of the various boolean and comparison operators for the boolean type. In contrast to statically typed languages like C or Java, Python does not need the explicit declaration of a variable's data type. In languages with dynamic typing, such as Python, the interpreter infers the data type of the variable based on the type of value sent to it.

Updated on: 23-Aug-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started