Skip to main content

Learn to code from nothing

This course assumes you have never written a line of code. Start with what a program is, then learn to read, write, test, and debug small Python programs. Eighteen numbered lessons take you through the basics, files, libraries, objects, local tools, and a final project. One practice lab after Functions helps you check an AI code suggestion using the ideas you have already learned.

New terms are explained as you meet them. Follow the path in order, pause to trace the examples, and use the exercises to check your understanding.

What you'll be able to practice​

  • Read a small program and predict what happens line by line.
  • Write a small program from scratch with variables, decisions, loops, and functions.
  • Work with collections and text, then read files and structured data.
  • Find and fix mistakes by reading errors and testing your explanation of the problem.
  • Check an AI suggestion against the task, test its behavior, and explain your decision to keep or change it.
  • Use local Python and Git, then combine your skills in a small command-line project — a program you run by typing a command.

These are foundations to keep practicing as you move into web development, AI engineering, data work, or other programming paths.

How the course works​

18 numbered lessons + 1 AI practice labTwo parts and seven groups, followed in order
19 checkpoint quizzesOne per numbered lesson and one for the lab; passing enables that page's Next link
17 runnable Python challengesWrite and test real Python in the page; challenges are practice rather than a progression gate
Self-directed paceAllow about 30–40 minutes for the AI lab; take more time for retries, explanations, setup, and the capstone

A reading-time estimate counts the page's words, not the time you need to solve exercises. You can split a lesson across sessions. The sidebar and direct lesson links remain available; use the quiz checkpoint along with solving fresh tasks and explaining results in your own words to decide when to continue.

Start in your browser without an account or a Python installation. The AI lab uses curated examples already on the page: you do not need a live AI tool, AI account, or paid model. Lesson 16 walks through installing Python on your computer; lesson 17 introduces local Git and an optional GitHub walkthrough that requires an account.

Save code and notes you want to keep. Submitted quiz results, solved-challenge flags, and manually marked lesson completion are saved in the current browser. Your challenge code, unfinished quiz answers, and notes are not autosaved. Progress does not sync to other devices, and clearing site data removes it. An internet connection is recommended: the browser's Python runtime is downloaded from an external service, so offline practice is not guaranteed.

Why Python?

We teach in Python because its syntax is relatively easy to read and it supports small scripts as well as larger programs. The ideas you practice here — values, decisions, repetition, functions, and collections — also help you learn other languages, even when their rules and notation differ.

The path​

The list below follows the same order as the sidebar. Complete Functions, work through Practice · Check an AI suggestion, then continue to Lists. The practice lab leaves the existing lesson numbers unchanged.

Part 1 — The basics

1 · First steps

  • 1. What programming is — Start from absolute zero — what a computer does, what a program is, how readable code becomes something a machine runs, and how to trace a tiny program by hand.
  • 2. Variables & types — What a variable really is, how to store and reassign values, the basic types (int, float, str, bool, None), dynamic typing, and why mixing types the wrong way breaks your program.
  • 3. Operators — Read any line of arithmetic, comparison, or logic and predict its value — operators, expressions vs. statements, division and modulo, precedence, == vs =, and Boolean and/or/not.

2 · Control flow

  • 4. Conditionals — How a program takes one path or another — the if statement, else, elif ladders, indentation, truthiness, and the bugs that bite every beginner.
  • 5. Loops — How to do the same work over and over — for loops and range, while loops, break and continue, the accumulator pattern, and nested loops.
  • 6. Functions — Define a named, reusable recipe once and call it many times — parameters vs arguments, return vs print, default values, early return, and local scope.
  • Practice · Check an AI suggestion — Predict, attempt, inspect, test, and explain a Python grading function. Practice checking a curated AI-style suggestion, then solve a fresh problem independently. No AI account needed.

3 · Data & text

  • 7. Lists — Store many values in one variable — indexing from zero, negative indexes, len, slicing, append, membership tests, and looping with the find-the-max accumulator pattern.
  • 8. Dicts & sets — Find things by name with a dictionary and track what's unique with a set — keys and values, safe lookups, looping, O(1) speed, and the counting and dedupe patterns interviewers love.
  • 9. Strings — Text is a string of characters — index and slice it, reverse it, use the everyday string methods, understand immutability, build text with f-strings, and write a vowel counter.

4 · Debugging

  • 10. Errors & debugging — Errors are on your side — read a traceback last-line-first, recognize the common error types, debug with print() and a hypothesis, and follow a repeatable problem-solving loop.

Part 2 — From scripts to programs

5 · Pythonic building blocks

  • 11. Tuples & comprehensions — Tuples (immutable, unpacking), list and dict comprehensions, and the enumerate/zip pair — the compact, idiomatic patterns that real Python code is actually written in.
  • 12. Modules & imports — import and from … import, the Python standard library (math, random, json, datetime), and installing third-party packages from PyPI with pip — how to build on top of code other people already wrote.
  • 13. Files & exceptions — Read and write text files with open() and with, and handle failure deliberately with try / except / else / finally, catching specific exceptions and raising your own.

6 · Objects & data

  • 14. Classes & objects — Why objects exist, and how to define one — class, __init__, attributes, methods, self, and creating instances — enough to read the object-oriented code in every real library.
  • 15. JSON & APIs — json.loads / json.dumps, navigating nested dicts and lists, and the concept of an HTTP API that returns JSON — the bridge from Programming Basics to the AI and web guides.

7 · Build for real

  • 16. Run Python locally — Install Python, learn the terminal basics, create a virtual environment with python -m venv, pip install into it, and run a .py file — the move from in-browser practice to building for real.
  • 17. Git & GitHub — What version control is and why, the mental model (commits, the repo, working dir → staging → commit), the core loop (git init/status/add/commit/log), pushing to GitHub, .gitignore for secrets and venv, and saving your hello.py project in GitHub — with traced command/output examples.
  • 18. Capstone project — Consolidate everything — functions, a class, JSON parsing, comprehensions, files, and error handling — into one small end-to-end command-line program that reads a data file and prints a report.

Where this leads next​

Once you can explain and build small programs, you can continue into a specialization, prepare for interviews, and practice by making projects of your own. Where this leads next connects this foundation to the rest of the guide collection. The AI practice lab teaches how to inspect a coding suggestion; the AI guide goes deeper into building AI applications.

Ready? Start with What programming actually is →