-
Explain mutability
-
Give an example of 2 data types which are mutable an 2 immutable
-
Mutability in Python refers to whether the value of certain type can be changed or not. For example, let's say you defined the following variable:
x = 2017
If you'll add 5 to it, the result is a completely different object because integers in Python are immutable:x = 2017 + 5
Mutable:
- List
- Dictionary
Immutable:
- Integer
- String