Python Tutorials - Herong's Tutorial Examples

https://www.herongyang.com/Python

Copyright © 2011-2023 Herong Yang. All rights reserved.

Python Tutorials This Python tutorial book is a collection of notes and sample codes written by the author while he was learning Python language himself. Topics include: installing Python environments on Windows, macOS and Linux computer; Python built-in data types; variables, operations, expressions and statements; user-defined functions; iterators, generators and list comprehensions; modules and packages; sys, os, and pathlib modules; Anaconda Python environment manager; Jupyter Notebooks; NumPy, SciPy libraries. Updated in 2023 (Version v2.14) with minor changes.

Table of Contents

About This Book

Running Python Code Online

What Is Python Online IDE

Using Python Shell at python.org

Running Python Code at pythonanywhere.com

Python IDE at online-python.com

Python IDE at sympy.org

Python on macOS Computers

Run Python Scripts on macOS

Install New Versions of Python on macOS

pip3 - Package Installer for Python 3

Python on Linux Computers

Run Python Scripts on Linux

Install Python 2 Environment on CentOS

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 - 'dict' for Dictionary Table

Variables, Operations and Expressions

What Is Variable

What Is Operation

What Is Expression

Conditional Expression - Ternary Operation

Assignment Expression - Walrus Operation

Statements - Execution Units

What Is Statement

"pass" Statement - Do Nothing Statement

Expression Statement - One Expression Only

"=" Statement - Assignment Statement

"del" Statement - Delete Statement

"import" Statement to Load Modules

"if" Statement for Conditional Execution

"while" Statement for Execution Loop

"for" Statement for Iterative Execution

"try" Statement to Catch Execution

"with" Statement for Context Manager

"match" Statement for Pattern Match

Function Statement and Function Call

Iterators, Generators and List Comprehensions

Classes and Instances

Modules and Module Files

What Is Module

"import module" - Two-Step Process

sys.modules - Listing Loaded Modules

importlib.reload(module) - Reloading Module

What Are Module Members

"from module import member" Statement

"from module import *" Statement

What Is __all__ List

__pycache__/module.version.pyc Files

What Is the __main__ Module

Packages and Package Directories

"sys" and "os" Modules

What Is "sys" Module

What Is "os" Module

Use "os" Module to Create Child Processes

Use "os" Module to Manage Files

"pathlib" - Object-Oriented Filesystem Paths

What Is "pathlib" Module

"pathlib.Path" - Path for Both Linux and Windows

"pathlib.Path" - Read and Write Operations

"pip" - Package Installer for Python

What Is "pip/pip2/pip3" Command

Use "pip" Package in Python Script

Install MySQL Connector/Python with "pip"

Using "pip" with Different Sources

Commonly Used Python Packages/Libraries

SciPy.org - Python Libraries for Science

NumPy - Python Library for Matrix operations

SciPy - Python Library for Mathematical Functions

pandas - Data Analysis and Manipulation

What Is 'pandas'

pandas.DataFrame/pandas.core.frame.DataFrame - The Table Class

pandas.core.series.Series - The Column Class

File Input and Output for DataFrame

Anaconda - Python Environment Manager

What Is Anaconda

Install Miniconda 3

Introduction to Conda Environment

Conda Configuration Files

Share Conda Environment with Others

Manage Packages in Conda Environment

Run Conda Environment Command in Background

Jupyter Notebook and JupyterLab

What Is Jupyter Notebook

Free Access of Jupyter Notebook and JupyterLab

Jupyter Notebook Architecture

Run Jupyter Notebook at mybinder.org

References

Full Version in PDF/EPUB

Keywords: Python, Script, Language, Tutorial, Example