Integer (int)
Whole numbers without decimal points.
๐ Scenario: Student Marks Management
math_marks = 95
Float (float)
Numbers with decimal points.
๐ฐ Scenario: Online Shopping – Billing System
price_per_item = 299.99
String (str)
Sequence of characters enclosed in quotes.
๐งพ Scenario: Invoice Generator
customer_name = "Sairam"
Boolean (bool)
Holds True or False values.
๐ Scenario: Login Authentication
is_authenticated = True
List (list)
Ordered, mutable collection of values.
๐ Scenario: E-Commerce Cart Items
cart_items = ["Laptop", "Mouse", "Keyboard"]
Tuple (tuple)
Ordered, immutable collection of values.
๐ Scenario: GPS Location Tracker
location = (17.385044, 78.486671)
Set (set)
Unordered collection of unique items.
๐ Scenario: Student Attendance System
students_present = {"Sairam", "Ravi", "Kiran"}
Dictionary (dict)
Collection of key-value pairs.
๐ฆ Scenario: Order Tracking System
order = {"order_id": "ORD102", "status": "Shipped"}
NoneType (None)
Represents absence of a value.
๐ Scenario: Profile Setup
profile_picture = None
๐ Summary Table
Data Type |
Purpose / Use Case |
Real-time Example |
int |
Counting, quantity, index |
Marks, product quantity |
float |
Precision values |
Price, temperature |
str |
Textual data |
Name, city, ID |
bool |
True/False checks |
Authentication, status |
list |
Multiple values (ordered) |
Cart items, to-do list |
tuple |
Fixed pair of values |
GPS coordinates, RGB values |
set |
Unique items |
Unique visitors, tags |
dict |
Structured records |
User profile, order info |
None |
Undefined / empty values |
Profile picture, missing config |
๐ Python Mutable vs Immutable Data Types
Data Type |
Mutable / Immutable |
Description / Behavior |
Example |
int |
Immutable |
Value cannot be changed once assigned |
x = 5 |
float |
Immutable |
Decimal values, reassignment creates new object |
price = 99.99 |
bool |
Immutable |
Either True or False, reassignment creates new object |
flag = True |
str |
Immutable |
Strings cannot be changed in place |
name = "Sairam" |
tuple |
Immutable |
Cannot change elements once defined |
coordinates = (1, 2) |
frozenset |
Immutable |
Immutable version of a set |
fs = frozenset([1, 2, 3]) |
bytes |
Immutable |
Immutable sequence of bytes |
b = b"hello" |
list |
Mutable |
Can add, remove, or change elements |
fruits = ["apple", "banana"] |
set |
Mutable |
Unordered collection of unique items |
tags = {"python", "aws"} |
dict |
Mutable |
Key-value pairs can be updated or removed |
user = {"name": "John"} |
bytearray |
Mutable |
Mutable version of bytes for binary data |
ba = bytearray([65, 66]) |