Data types in Python
14 Jun 2024What is a Data Type?
In programming, a data type is a classification that specifies which type of value a variable can hold. It defines the operations that can be performed on the data and the way the data is stored in memory. Python is dynamically typed, which means that you don’t need to explicitly declare the data type of a variable; the interpreter infers it at runtime.
Mutable vs. Immutable Objects
In simple words, the value assigned to a variable cannot be changed for the immutable data types. For example, String is an immutable data type in Python. We cannot change its content, otherwise, we may fall into a TypeError. Even if we assign any new content to immutable objects, then a new object is created (instead of the original being modified).