In our previous article, we discussed Python variables. We discussed how a variable is created and assigned a value in Python. In this article, we would discuss Python data types.
As we discussed, we can create a variable and assign a value to it. And, the assigned value can be of various data types. For example, we can assign a string, an integer, a float, or a boolean value to a variable. In a programming language, a data type is an attribute that tells the compiler or the interpreter how the programmer wants to use the data.
Python supports the following basic data types:
- string
- integer
- float
- complex
- list
- tuple
- range
- dictionary
- set
- boolean
- bytes, etc.
As we discussed, we do not need to declare a variable in Python before using it. Instead, we can create a variable and assign a value to it directly. However, if we want to know the data type of a variable, we can do so in the following way:
x = 19 print(type(x))
The above program should print the following output:






0 Comments