Python Basics
Python Data Types
Every value in Python has a data type, which tells Python what kind of data it is and what operations you can perform on it.
Why Data Types Matter
Data types determine how Python stores and processes a value. For example, you can do math with numbers but not directly with plain text, and knowing the type of your data helps you avoid errors.
Python's Built-in Data Types
| Type | Example | Description |
|---|---|---|
| int | 25 | Whole numbers, positive or negative |
| float | 3.14 | Decimal (floating-point) numbers |
| str | "hello" | Text, written inside quotes |
| bool | True / False | Represents true or false values |
| list | [1, 2, 3] | Ordered, changeable collection |
| tuple | (1, 2, 3) | Ordered, unchangeable collection |
| set | {1, 2, 3} | Unordered collection of unique items |
| dict | {"a": 1} | Key-value pairs |
| None | None | Represents "no value" or empty |
age = 25
price = 3.14
name = "Learning Python"
is_active = True
fruits = ["apple", "mango"]
coordinates = (10, 20)
unique_ids = {101, 102, 103}
student = {"name": "Neha", "age": 22}
result = NoneChecking a Variable's Type
Python has a built-in function called type() that tells you the data type of any value or variable, which is very useful while debugging.
print(type(age))
print(type(name))
print(type(fruits))Lists, tuples, sets and dicts are called collection types because each can hold multiple values inside one variable.
You will explore numbers, strings, booleans and each collection type in much more depth in the upcoming lessons.
