In Python (programming language), data types define the type of value a variable can store. Every variable in Python holds data of a specific type, such as numbers, text, or collections of data.

Python automatically determines the data type based on the value assigned to a variable.

Example:

x = 10
name = "Alice"
price = 5.5

Here Python automatically assigns the correct data type.


πŸ“¦ Common Python Data Types

1️⃣ Numeric Types

Numeric data types store numbers.

Integer (int)

Whole numbers without decimals.

Example:

age = 25
year = 2026

Float (float)

Numbers with decimal points.

Example:

price = 19.99
temperature = 36.5

Complex (complex)

Numbers with a real and imaginary part.

Example:

x = 3 + 4j

πŸ”€ String (str)

Strings store text data.

Strings are written inside single or double quotes.

Example:

name = "Rahul"
message = 'Hello Python'

βœ”οΈ Boolean (bool)

Boolean data types store True or False values.

Example:

is_student = True
is_logged_in = False

Booleans are commonly used in conditions and comparisons.


πŸ“š Sequence Types

List (list)

A list stores multiple values in a single variable and is changeable.

Example:

fruits = ["apple", "banana", "mango"]

Tuple (tuple)

A tuple also stores multiple values but cannot be changed after creation.

Example:

coordinates = (10, 20)

πŸ”’ Set (set)

A set stores unique values and does not allow duplicates.

Example:

numbers = {1, 2, 3, 4}

πŸ“– Dictionary (dict)

A dictionary stores data in key-value pairs.

Example:

student = {
"name": "Rahul",
"age": 21,
"course": "Python"
}

πŸ§ͺ Checking Data Types

You can check the type of a variable using the type() function.

Example:

x = 10
print(type(x))

Output:

<class 'int'>

⭐ Summary of Python Data Types

Data TypeExample
int10
float10.5
complex3+4j
str“Hello”
boolTrue
list[1,2,3]
tuple(1,2,3)
set{1,2,3}
dict{“name”:”Rahul”}

βœ… Understanding data types is essential because they determine how data behaves in Python (programming language) programs.