A single-page, self-contained Python reference guide (basics → data structures → OOP → advanced topics), with practice questions after every chapter.
output.html— the final page. Open it directly in a browser, or serve it from GitHub Pages.generate.py— the source of truth. All chapter content lives in aCHAPTERSlist here.
Don't hand-edit output.html — edit generate.py instead and regenerate:
python3 generate.pyEach chapter is defined with a small chapter(...) call, e.g.:
chapter("for-loop", "08", "For Loop", "Control Flow", [
p("A for loop walks through any iterable..."),
code("""
for i in range(5):
print(i)
"""),
], [
q(1, "Print all even numbers from 1 to 20 using a for loop.", "1 to 20", "2 4 6 ... 20"),
])p(...)— a paragraphh3(...)— a subheadingcode(...)— a syntax-highlighted code blockul([...])— a bullet listtable(headers, rows)— a reference tablenote("info"|"warn", title, text)— a callout boxq(num, text, input, output)— a practice question (input/output are optional)
To add a new chapter, add a new chapter(...) call anywhere in the list — order in the list controls order on the page and in the sidebar nav. Chapters with the same 4th argument (group name) get grouped under one sidebar label.
git init
git add .
git commit -m "Initial Python guide"
git remote add origin <your-repo-url>
git push -u origin mainIf you want it live on the web for free, enable GitHub Pages on the repo. The site now generates an index.html homepage automatically, so GitHub Pages will serve it correctly.