Python Tutorials - Herong's Tutorial Examples - v2.15, by Herong Yang
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):
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
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
Function Statement and Function Call
List, Set and Dictionary Comprehensions
Packages and Package Directories
"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