Junior — Middle
What mutable data types do you know in programming?
sobes.tech AI
Answer from AI
Mutable (changeable) data types in programming are those whose contents can be modified after the object is created.
In Python, mutable types include:
- list — lists, elements can be changed, added, removed
- dict — dictionaries, key-value pairs can be modified
- set — sets, elements can be added and removed
- bytearray — a mutable array of bytes
Example:
my_list = [1, 2, 3]
my_list.append(4) # list has changed
my_dict = {'a': 1}
my_dict['b'] = 2 # dictionary has changed
Unlike them, types such as int, float, str, tuple are immutable.