Professional Documents
Culture Documents
Python19th June2024 07.drawio
Python19th June2024 07.drawio
Python19th June2024 07.drawio
Fundamental data types (also known as built-in types or primitive types) in Python are the basic building
blocks provided by the language. These types are directly supported by Python and include:
Immutability in Python
Immutability refers to objects whose state cannot be changed after they are created.
Immutable objects include:
1. Integers (int)
2. Floating-point numbers (float)
3. Booleans (bool)
4. Strings (str)
5. Tuples (tuple)
6. Frozensets (frozenset)
7. Complex numbers (complex)
Fundamental Data Types vs Immutability
Key Differences
1. Nature:
Fundamental Data Type: Refers to the basic data types built into the Python language.
Immutability: Refers to the characteristic of an object that prevents modification after it is created.
2. Scope:
Fundamental Data Type: Encompasses the simplest data types provided by Python.
Immutability: Can apply to both fundamental and non-fundamental data types.
3. Mutability:
Fundamental Data Type: Some fundamental data types are mutable (like list), while others are
immutable (like int).
Immutability: Specifically concerns whether an object can be modified after creation.
4. Examples:
Fundamental Data Types: The basic data types built into Python (e.g., int, float, bool, str,
complex).
Immutability: A property of an object that cannot be changed after its creation. In Python, many
fundamental data types are immutable (e.g., int, float, bool, str), but this concept also applies to
more complex types like tuples and frozensets.