Data types in Python
Python is a dynamic language. That is, we do not need to specify the type of the variable while writing it. The Python interpreter automatically learns the type of the value. Variables in Python contain values, and each value comes with a specific data type.
A variable can contain different types of values. For example, a person's name should be stored as a string while his age should be stored as an integer.
Python provides different standard types of data
Data types in Python
Numbers
- Integer
- complex number
- float number
Sequence
- string
- List
- tuple
Boolean value
set
dictionary
You can get the data type of any object using the type() function
Example:
a = 3
print(type(a))
The output will be:
a = 3
print(type(a))
In the previous example, we defined a variable named a and gave it the value 3, which is of data type integers. Then the print command and inside it the type() function to specify the type of the variable value.
In this article, we gave a brief introduction to data types in Python. We will discuss each of them in detail later.
Tags
Python python data types
Share page
About author
Ahmed Obaid
Hello, I am Ahmed Obaid, an Egyptian Arabic programmer. I would like to put my experiences learning Python on this site So that it will be a reference for you and me as well.
Sign up to leave a comment