Different Data Types in Python
In Python, data types define the type of data a variable can store and the operations that can be
performed on it.
1. Numeric Data Types
1 int: Stores whole numbers (e.g., x = 100)
2 float: Stores decimal numbers (e.g., y = 10.5)
3 complex: Stores complex numbers (e.g., z = 3 + 4j)
2. String (str)
1 Sequence of characters enclosed in quotes
2 Immutable (cannot be changed after creation)
3 Example: name = 'Python'
3. List
1 Ordered collection of items
2 Mutable and allows duplicates
3 Example: numbers = [1, 2, 3]
4. Tuple
1 Ordered but immutable collection
2 Allows duplicates
3 Example: t = (1, 2, 3)
5. Set
1 Unordered collection of unique elements
2 No duplicates allowed
3 Example: s = {1, 2, 3}
6. Dictionary (dict)
1 Stores data in key-value pairs
2 Keys must be unique
3 Example: student = {'name': 'Ram', 'age': 20}
7. Boolean (bool)
1 Represents True or False values
2 Used in conditions
3 Example: x = True
8. Binary Data Types
1 bytes, bytearray, memoryview
2 Used for binary data storage
3 Example: b = b'hello'
9. None Type
1 Represents no value or null
2 Example: x = None
Conclusion: Python provides a variety of data types that help in efficient data storage and
manipulation.