Introduction to Data Type

This section provides a quick introduction of Python basic data types including NoneType, bool, int, float, bytes, str, tuple, list, dict, etc.

What Is Data Type? A data type is defined as a class of data objects who shares the same data structure, properties and operations.

There are two very important statements about Python you should remember:

You can use the type(object) function to see the class name that defines the given data object:

>>> type(314)
<class 'int'>

>>> type(3.14)
<class 'float'>

>>> type('3.14')
<class 'str'>

>>> type(True)
<class 'bool'>

>>> type(None)
<class 'NoneType'>

>>> type(())
<class 'tuple'>

>>> type([])
<class 'list'>

>>> type({})
<class 'dict'>

>>> type(type)
<class 'type'>

>>> type(exit)
<class '_sitebuiltins.Quitter'>

Python data types can be grouped into hierarchical trees as shown below (devopedia.org):

Python Data Type Hierarchy
Python Data Type Hierarchy

In this chapter, we will cover the following basic data types:

For more information, see Python reference document "Built-in Types" at https://docs.python.org/3/library/stdtypes.html.

Table of Contents

 About This Book

 Running Python Code Online

 Python on macOS Computers

 Python on Linux Computers

Built-in Data Types

Introduction to Data Type

 Common Features of All Data Types

 Data Type - NoneType for Nothing

 Data Type - 'bool' for Boolean Values

 Data Type - 'int' for Integer Values

 Data Type - 'float' for Real Numbers

 Data Type - 'bytes' for Byte Sequence

 Data Type - 'str' for Character String

 Data Type - 'tuple' for Immutable List

 Data Type - 'list' for Mutable List

 Data Type - 'set' for Unordered Collection

 Data Type - 'dict' for Dictionary Table

 Variables, Operations and Expressions

 Statements - Execution Units

 Function Statement and Function Call

 Iterators and Generators

 List, Set and Dictionary Comprehensions

 Classes and Instances

 Modules and Module Files

 Packages and Package Directories

 "sys" and "os" Modules

 "pathlib" - Object-Oriented Filesystem Paths

 "pip" - Package Installer for Python

 SciPy.org - Python Libraries for Science

 pandas - Data Analysis and Manipulation

 Anaconda - Python Environment Manager

 Jupyter Notebook and JupyterLab

 References

 Full Version in PDF/EPUB