Data types in Python

13-12-22 Ahmed Obaid 5128 0

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