immutable and mutable - ibrahimrifats/Back-End-development GitHub Wiki
**Here's a list of some commonly used immutable and mutable data types in Python**
**Immutable Data Types:**
1. Numbers: int, float, complex
2. Strings
3. Tuples
4. Frozen Sets
**Mutable Data Types:**
1. Lists
2. Sets
3. Dictionaries
Here are examples of each type:
**Immutable:**
```python
# Numbers
my_integer = 42
my_float = 3.14
my_complex = 1 + 2j
# Strings
my_string = "Hello, World!"
# Tuples
my_tuple = (1, 2, 3, "apple")
# Frozen Sets
my_frozen_set = frozenset([1, 2, 3])
Mutable:
# Lists
my_list = [1, 3, 4, 5, True, False, 'rifat']
# Sets
my_set = {1, 2, 3, 'apple'}
# Dictionaries
my_dict = {'name': 'John', 'age': 30, 'city': 'New York'}
The key difference between immutable and mutable data types is that you can change the elements of mutable objects after creation (e.g., adding or removing items from a list, set, or dictionary), whereas immutable objects cannot be modified after creation.