Python Progamming/Basics of Python Language

Python DataTypes

Updated on January 12, 2026
1 min read

Python DataTypes

Every value in Python has a type. The type tells Python what kind of data it is dealing with and what operations can be performed on it. Without data types, a program would not know the difference between a number, a word, or a list of items.

In Python, when you create a variable, you do not manually declare its type. Python automatically detects the type based on the value you assign. This is called dynamic typing.

Example:

age = 20        # integer
price = 99.5   # float
name = "Mohan" # string

Here, Python decides the type of each value without you telling it.

Main Data Types in Python

Python provides several built-in data types, but the most important ones are:

Integer (int)

Used to store whole numbers.

Example: 10-5200

Float (float)

Used to store decimal numbers.

Example: 3.149.80.5

String (str)

Used to store text.

Example: "Hello""Python"

Boolean (bool)

Used to represent true or false values.

Example: TrueFalse

List (list)

Used to store multiple values in a single variable.

Example:

marks = [80, 90, 75]

Tuple (tuple)

Like a list, but cannot be changed.

Example:

colors = ("red", "green", "blue")

Set (set)

Stores unique values.

Example:

numbers = {1, 2, 3}

Dictionary (dict)

Stores data in key–value pairs.

Example:

student = {"name": "Mohan", "age": 21}

Why Data Types Matter

Data types control what you can do with a value.

You can add two numbers.

You cannot add a number to a string.

Example:

10 + 5      # works
"10" + "5"  # works (joins text)
10 + "5"    # error

Python stops you because mixing incompatible data types leads to bugs.

Checking Data Types

You can check the type of any value using type().

Example:

x = 10
print(type(x))   # <class 'int'>

Conclusion

Data types are the DNA of a Python program. They define how data is stored, processed, and combined. If you don’t understand data types, you don’t understand Python—everything else is built on top of them.

Python DataTypes | Python Progamming | Learn Syntax