Common Objects and their data types in Python
1. List []
-
Modifiable (can change values)
-
Ordered (keeps the order of items)
-
Can store mixed data types
-
Example:
[1, 2, 3, a, b, c]
2. Tuple ()
-
Non Modifiable (cannot change values after creation)
-
Ordered
-
Can store mixed data types
-
Example:
(1, 2, 3, a, b, c)
3. Dictionary {}
-
Key-value pair
-
Modifiable
-
Unordered
-
Example:
{"name": "Kavi", "age": 25}
4. Set {}
-
Modifiable
-
Unordered (no index)
-
Unique elements only
-
Example:
{1, 2, 3}
5. String "" or ''
-
Non Modifiable
-
Ordered
-
Example:
"Hello", "world"
6. Integer (int)
-
Whole numbers
-
Example:
10
7. Float (float)
-
Decimal numbers
-
Example:
3.14
8. Boolean (bool)
-
True or False
-
Example:
True
9. NoneType (None)
-
Represents nothing / null
-
Example:
None
Comments
Post a Comment