We will study Python data types in this lesson of the Python tutorial. We’ll learn more about Python’s dynamic typing capability and its various data types, including Numbers, Strings, Lists, Tuples, Sets, etc.
Unlike statically typed languages like C or Java, Python does not require the data type of a variable to be declared. When a variable is allocated a particular type of value in a dynamically typed language like Python, the interpreter will automatically predict the data type of the variable.
Core Data Types in Python
A data type is a classification of the different kinds of values that can be assigned to variables, as the name would imply. The fact that we don’t have to explicitly state the data type when declaring a variable in Python has already been demonstrated, but it’s still vital to comprehend the many kinds of values that can be assigned to variables in Python. After all, the value assigned to a variable determines its data type.
Python data types are categorized into two as follows:
- Mutable Data Types: Python data types that allow a variable’s value to be modified. Python supports several mutable data types, such as set, list, user-defined classes, and dictionary.
- Immutable Data Types: Python data types that prevent changing the value a variable has been assigned. Integer, decimal, float, tuple, bool, range, and text are examples of immutable data types in Python.