Hierarchy of standard Python Data Types and its Real Time usage

Hello readers, welcome back to Python Data Types. Below is a list of the Data types that are integrated into Python. Extension modules (written in C, Java or other languages, depending on the implementation) can define additional types. Future versions of Python can add types to the type hierarchy (for example, rational numbers, integer arrays stored efficiently, etc.).

Some of the type descriptions below contain a paragraph that lists “special attributes.” These are attributes that provide access to the implementation and are not intended for general use. Its definition may change in the future.

In Python, you have several types of standard composite data available by default in the interpreter, such as the numeric types, sequences, mappings, and sets used to group other values.

In the case of data structures, variables and constants are used, which use operators to deal with standard data types.

Python Data Types:

  • Numeric Data Type
  • String Data Type
  • List and other Data Structures

The standard composite data types can be classified as the following two:

  • Mutable: its content (or said value) can be changed at runtime.
  • Immutable: its content (or said value) can not be changed at runtime.

Note: The data type ‘long’ supports in Python 2.7 as it understands the long integer as ‘type’ ‘long’. But whereas in Python 3.7 it is dropped and used as the ‘type’ ‘int’.

The standard compound data types can be summarized in the following table:

Type category First name Description
Immutable numbers int whole
long whole long
float floating comma
complex complex
bool boolean
Immutable sequences str string of characters
unicode Unicode character string
tuple tuple
xrange immutable range
Mutable sequences list list
range mutable range
Mappings dict dictionary
Mutable sets set mutable set
Immutable sets frozenset immutable set

Objects Type

Type objects represent the various object types. An object type is accessed by the built-in type () function. There are no special operations on types. The standard module typesdefines the names for all standard integrated types.

The types are written like this: “<type ‘int’>”.

The syntax to know the type of a variable or its value by using built-in type() function:

width = 10
height = 5.91

For more python data types examples, kindly click here.

To know the more important Python 3 Basics, please click here.

Hierarchy of standard Python Data Types and its Real Time usage
Rate this post

One Response - Add Comment