Companion resources
The printed book contains the explanations, essential examples and exercises. Companion files make it easier to run and adapt the examples locally.
Answers and teaching resources
. Access may be required. Each activity link opens its matching answer and explanation. Instructor access is required; source ambiguities and validation evidence are recorded with each solution.
Choose a lesson
- Introduction
- Installation and Setup
- Python Interpreter
- First Programs
- IPython Interpreter
- Python Package Installation
- Python Basics
- Numbers
- Strings
- Variables
- Indentation, Semicolons, and Comments
- Input and Output
- Type Casting (Type Conversion)
- Boolean Values and Logical Expressions
- Operators in Python
- String Formatting Techniques
- Data Types and Collections
- Lists
- Tuples
- Sets
- Dictionaries
- Working with Nested Data Structures
- Control Flow
- Conditional Statements (if, elif, else)
- The match Statement
- While Loops
- For Loops
- Python Functions
- Function Arguments and Return Values
- Flexible Arguments: *args and kwargs
- Scope and Decorators
- Python Built-in Functions
- Lambda Functions, Recursion, and Generators
- Introduction to Modules
- The datetime Module
- The math Module
- The json Module
- The re (Regular Expressions) Module
- Python PIP
- The try and except Blocks
- Virtual Environment
- What Is OOP?
- Creating Classes and Objects
- Initializing Objects with __init__ and self
- Object Attributes and Methods
- Identity, State, and Behavior
- Instance and Class Members
- Instance and Class Attributes
- Instance and Class Methods
- Coding Challenge: Tracking Books Across All Libraries
- Structuring Code in OOP
- Inheritance
- Polymorphism
- Encapsulation
- Multiple Inheritance
- Composition: “Has-a” Relationships
- Abstract Classes
- Interfaces and Behavioral Contracts
- Introduction to UML
- Use Case Diagram
- Component Diagram
- Information or Data Model
- Model–View–Controller (MVC) Architecture
- Class Diagram
- Object Diagram
- From Diagram to Code
- “Is-a” and “Has-a” Relationships
- Activity Diagram
- Sequence Diagram
- Project: University Course System
- Introduction
- Specialized Data Structures
- Counting with Counter
- Grouping with defaultdict
- Lightweight Records with namedtuple
- Double-Ended Queues with deque
- Iteration Tools with itertools
- Priority Queues with heapq
- Categorical Data with Enum
- Summary and Coding Challenges
- File Handling & Serialization
- File Handling in Python
- File Serialization
- Error Handling
- Exercise 1 — Building a Safe Calculator (Input Validation + Specific Exceptions)
- Exercise 2 — Student Registration Validator (Raising & Custom Exceptions)
- Python Testing
- Unit Testing with unittest
- Unit Testing with pytest
- Concurrency & Parallelism
- The Global Interpreter Lock (GIL)
- Threads: Best for I/O-Bound Tasks
- Processes: Best for CPU-Bound Tasks
- Async I/O with asyncio
- Project: Parallel Word Counter
- APIs & Web Scraping
- Understanding HTTP
- HTML Basics
- Fetching and Parsing Online Data
- Ethics & Responsible Web Scraping
- Project: Fetch & Parse Real Website Data