Data types specify the differrent sizes and values that can be stored in the variable. For example, Python stores numbers, strings, and a list of values using different data types.
Python is a dynamically typed language. Therefore, we do not need to specify the variable's while declaring it. Whatever value we assign to the variable based on that data type will be automatically assigned. For example, name = 'John' here Python will store the name variable as a str data type.
No matter what value is stored in variable (object), a variable can be any type like int, float, str, list, set, tuple, dict, bool, etc.
There are mainly four types of basic or primitive data types available in Python
Numeric: int, float, and complex
Sequence: string, list, and tuple
Set
Dictionary(dict)
To check the data type of variable use the built-in function type() and the type() function returns the data type of the variable.
In this article, we will learn the following Python data types in detail.
| Data Type | Description | Example |
| int | To store integer values | n = 10 |
| float | To store decimal values | n = 10.58 |
| complex | To store complex numbers (real and imaginary part) | n = 10 + 20j |
| str | To store textual or string data | str = 'John' |
| bool | To store boolean values | flag = True |
| list | To store a sequence of mutable data | ls = [1, 2, 'John', 'Jenny'] |
| tuple | To store sequence immutable data | t = ( 1, 2, 'a', 'b') |
| dict | To store key: value pair | dic = {1: 'John', 2: 'Jenny'} |
| set | To store unorder and unindexed values | s = {1, 3, 5} |
| frozenset | To store immutable version of the set | f_set = frozenset({5,7}) |
| range | To generate a sequence of number | numbers = range(10) |
| bytes | To store bytes values | b=bytes([1,2,3,5]) |



