PythonPython Data TypesTypes of Data Types

Python Data Types

Python supports several built-in data types, each designed to handle specific kinds of information. Here’s an overview:

Data TypeClass(es)Description
Numericint, float, complexStores numeric values, including integers, decimals, and complex numbers.
StringstrHolds sequences of characters.
Sequencelist, tuple, range, bool, set, frozensetStores collections of items, including ordered (like lists, tuples) and unordered (like sets) collections.
MappingdictMaintains data in key-value pairs.
None TypeNoneTypeRepresents the absence of a value or null.
BooleanboolRepresents logical values: True or False.
Setset, frozensetStores a collection of unique items.

In Python, each data type is implemented as a class. These classes provide built-in methods and functionalities that allow you to interact with and manipulate data efficiently.


To write efficient programs, it’s essential to choose the right data type. Let’s explore the various data types available in Python.

1. Numeric Data Types

  • Integer (int): Whole numbers (positive or negative), without a decimal point.

    marks = 20
    Rno = 12
    x = -4
  • Float (float): Numbers with decimals. Even an integer stored as a float is represented with a decimal (e.g., 9.0).

    weight = 56.8
    y = -10.5
  • Complex (complex): Numbers with a real and imaginary part.

    distance = 2 + 1j

2. Boolean Data Type

The Boolean type represents truth values: True or False. You can also use 1 for True and 0 for False.

state = False
print(type(state))  # Output: <class 'bool'>

3. Dictionary Data Type

A dictionary is an unordered set of key-value pairs, defined using curly braces {}. Each key must be unique, while values can repeat.

medals = {'TeamA': 25, 'TeamB': 32, 'TeamC': 14}

4. Sequence Data Types

  • String (str): Holds any type of characters, enclosed in single (' ') or double quotes (" ").

    Houseno = 'B-19'
    name = "Neer"
  • List (list): A compound data type holding a group of values, defined using square brackets [ ]. Lists are mutable.

    student = [12, 'Niyasa', 60.5]
    vowels = ['a', 'e', 'i', 'o', 'u']
    marks = [21, 20, 17, 24]
  • Tuple (tuple): Similar to lists but immutable, defined using round brackets ( ).

    days = ('Mon', 'Tue', 'Wed')