Chapters¶
This textbook is organized into 38 chapters covering 450 concepts, guiding you from your very first Python program all the way to machine learning.
Chapter Overview¶
- Welcome to Python and Skulpt — Meet Monty, run your first
print(), writeimport turtle, and see what's coming. - Python Code Structure — Indentation, code blocks, keywords, whitespace, and named colors.
- Variables and Numbers — Storing data with variables, naming rules, integers, floats, and None.
- Functions and Objects — Defining functions with
def, calling them, and a first look at objects. - Drawing with Turtle Graphics — Your first real turtle programs: movement, turning, pen control, and color.
- Math and Arithmetic — All the arithmetic operators, order of operations, and multiple assignment.
- For Loops and Drawing Shapes —
forloops withrange(), drawing polygons, circles, and star patterns. - Working with Strings — String type, quotes, concatenation, escape characters, and writing text on the canvas.
- Making Decisions with If/Else — Booleans, comparisons,
if,elif,else, and nested conditionals. - While Loops and Animation —
whileloops,break,continue,time.sleep(), and animated turtle drawing. - Functions with Parameters and Scope — Default parameters, keyword arguments, local/global scope, and return values.
- Colors, Fill, and Turtle Art — Hex colors, RGB, HSL,
begin_fill()/end_fill(), transparency, and color theory. - User Input and Type Conversion —
input(), converting strings to numbers,type(), and validation basics. - String Methods and Formatting — Indexing, slicing,
split()/join(), f-strings, and string comparison. - Lists — Basics — Creating lists, indexing, slicing,
len(), membership, mutable vs immutable. - Lists — Methods and Patterns —
append()/pop()/sort(), iteration, nested lists, comprehensions, stacks, queues. - Modules and Random Numbers —
from...import, aliases, and therandommodule for games and art. - Math Module and Turtle Projects —
math.sqrt(),sin()/cos()/pi, turtle sine wave, and a turtle race. - More Booleans and Conditionals — Truthiness, short-circuit evaluation, ternary expressions, and
match/case. - Tuples and Sets — Immutable sequences, tuple unpacking, sets, union/intersection/difference.
- Dictionaries — Key-value stores, all dict methods, iteration, nesting, and comprehensions.
- Advanced Collections and Built-in Functions —
enumerate(),zip(),*args/**kwargs,map()/filter(),max()/min()/sum(). - Error Handling and Debugging — Exception types, tracebacks,
try/except,raise,assert, and debugging strategies. - Recursion and Fractals — Recursion, base cases, lambda functions, nested functions, and fractal turtle art.
- Object-Oriented Programming — Classes,
__init__(),self, instances, inheritance, dunder methods. - File Input and Output —
open(), file modes, reading/writing,withstatement, CSV files. - Standard Library and JSON — Custom modules,
os,sys,json,datetime,collections,itertools. - Python Development Tools — VS Code, Thonny, Jupyter, pip, virtual environments, Conda, Raspberry Pi.
- Text Processing and Regular Expressions — The
remodule, patterns, character classes, quantifiers, groups. - Algorithms and Data Structures — Stacks, queues, graphs, BFS, DFS, sorting algorithms, binary search, Big-O.
- Advanced Functions and OOP —
map()/filter(),dir()/help(), custom exceptions, static methods,@property. - Data Visualization with matplotlib — Line plots, scatter, bar, histogram, legends, saving figures, subplots.
- NumPy and Scientific Computing — Arrays, broadcasting, reshaping,
linspace(), element-wise math, sine wave plot. - Image Processing with Pillow — Opening images, pixel data, resize/crop, color conversion, saving.
- Advanced Turtle and Event-Driven Programming —
onscreenclick(), color picker, maze visualization, Jupyter canvas, event handlers. - Computational Thinking and Best Practices — DRY, modularity, refactoring, version control, decomposition, abstraction.
- Machine Learning Foundations — ML overview, Keras, sequential models, dense layers, MNIST, overfitting.
- Neural Networks and MNIST — Conv2D, MaxPooling, dropout,
compile()/fit()/evaluate(), CNNs.
How to Use This Textbook¶
Start at Chapter 1 and work through in order — each chapter builds on the previous ones. Chapters 1–12 focus on turtle graphics so you get visual, immediate feedback on every concept. From Chapter 13 onward the focus shifts to Python's full power: collections, files, objects, algorithms, and data science. Every chapter ends with a "TODO: Generate Chapter Content" marker — content will be added progressively.
Note: Each chapter index lists the exact concepts covered. Complete prerequisites before jumping ahead.