Python Tutorials - Herong's Tutorial Examples
∟Built-in Data Types
This chapter provides introductions and tutorial examples about built-in data types. Topics include introductions to common features of all data types; some basic data types: NoneType, bool, int, float, bytes, str, tuple, list, set and dict.
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
Takeaways:
- All data in a Python program is represented by objects.
- Every object has an identity, a type and a value.
You can use id(object) and type(object) to see its identity and data type.
- The value of an immutable object can not be changed.
- Every object can be implicitly casted to a Boolean value.
- "NoneType" has a single object, the null object, named as "None".
- "bool" has two objects named as "True" and "False".
- "int" is immutable and have objects for all integer values.
- "float" is immutable and can store any real number
in double precision (using 8-byte storage) format according to the IEEE 754 standard.
- "bytes" is immutable and can store any sequence of bytes.
- "str" is immutable and can store any sequence of Unicode characters.
- "tuple" is immutable and can store any sequence of objects.
- "list" is mutable and can store any sequence of objects.
- "set" is mutable and can store any collection of objects.
- "dict" is mutable and can store any collection of key-value pairs.
Table of Contents
About This Book
Running Python Code Online
Python on macOS Computers
Python on Linux Computers
►Built-in Data Types
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