Getting started
Welcome. This course teaches the fundamentals of programming using Python. The focus is on the core ideas (variables, control flow, loops, functions, objects, and data structures), not on clever or optimal Python. Once you have the ideas you can carry them to any language.
The goal is to empower you to program independently, outside of this website. Some of the work happens right here in your browser, where there is nothing to install. The rest happens on your own computer, with real programming tools like the ones professional programmers use. "How this course works" below explains both.
Before you start: how to learn this
Learning to program means spending a lot of time confused. That is normal. It is not a sign you are bad at it, and everyone who programs has been through it. Keep these ideas with you:
- Keep going when something does not make sense. Not understanding a page is not a reason to stop. Move on and come back later. Ideas that confused you at first make sense gradually as you see more of the picture.
- You do not have to finish a step to continue. If you cannot complete an exercise or cannot get something to work, you can still move forward.
- The setup pages are optional background. Section 1 explains a lot about the tools programmers use: terminals, Python, editors. Some of it is context, and you do not have to absorb it. If it feels like too much, skip it and start the lessons in Section 2. The exercises there run in your browser with nothing to install, and they are real, valuable practice. You can set up the local tools whenever you are ready.
How this course works
The course has two halves that work together:
- Lessons and exercises, here in your browser. Each lesson explains an idea with code you can run on the page. Nothing to install.
- Projects, on your own computer. Each section ends with a larger project you build locally, with a real code editor and a terminal, the way a working programmer would.
The lessons teach each idea. The projects are where you practice using it to build something bigger, and where you learn the tools you will need to program outside this site.
Lessons in your browser
Each lesson explains a concept with code you can run. The code lives in boxes
called cells, and it runs in the page itself (Python runs in your browser),
so there is nothing to install to follow along. Press Run on the cell below.
Then change the code and run it again. You could change the text inside the
quotes, or the number inside range(3), or both, and see what happens. This
plain kind of cell is just for trying things. Nothing is graded.
A cell works like a small code editor. These keys make writing code smoother. They are nice to know and mostly optional, so you can ignore them for now and come back later. If you want to try them, use the cell you just ran above:
| Keys | What they do |
|---|---|
| Tab | Indent by four spaces |
| Shift + Tab | Take an indent back |
| Enter | Start a new line at the same indentation, one level deeper after a line that ends in a colon |
| Shift + Enter | Run the cell (Ctrl + Enter works too) |
| Esc then Tab | Leave the box, if you move around the page with the keyboard |
The cell above is for experimenting. Two other kinds of cell ask you a question instead. Both tell you whether you got it right. The difference is whether they count.
Quizzes count. You write the answer, press Run, and the cell tells you whether it passed, with a message to guide you if it did not. Hints are there when you get stuck. A quiz has a solid orange border, and when you pass it, it turns green. A lesson is finished when you have passed all of its quizzes. Try this one. First press Run without changing anything. The cell fails, and the message tells you why. Then change the code and press Run again to see it pass:
- Change the code so that the program prints
Hello, Python!.
Hint 1
The starter code has a placeholder. We'll learn about print and strings
later in the course. For now replace the whole line with
print("Hello, Python!") and run again.
Checks do not count. They are quick questions that help you notice whether an idea sank in. You can skip one, retry it as often as you like, and nothing is recorded. A check has a dashed border. Here is one:
Check your understanding. Predict what this program prints. The program is not run for you. Press Run once to see what the cell says, then replace None with the text you expect, in quotes. The message after the first run shows you the exact line to type. Press Run again to pass.
count = 4
print(count + 2)
Hint 1
The answer here is the string "6", not the number 6. So you would
replace output = None with output = "6".
We'll learn more about numbers and text later; this is just an introduction to checks.
Projects on your own computer
Each section ends with a larger project that you build locally, in a real code editor (the notes assume VS Code). The lessons teach the concept. The project is where you practice building something bigger, the way you would in real work. Setting up an editor and running your own Python files is part of learning to program, so projects live outside the browser on purpose.
Every project works the same way. Read the description, create a file with the name it gives, write your solution in VS Code, and run it in the terminal. You will find each project in the sidebar, in a Projects group at the bottom of its section, and in a list at the end of the lesson it follows.
You do not need to set anything up yet. The next pages explain the tools, and the first project, Your first Python file, walks you through the setup step by step.
How to move through it
Use the section list on the left to jump between lessons, or the Previous and Next buttons at the bottom of each lesson to go in order. Start with the next lesson and work forward.
Solutions and tests
Every project after the first comes with a collapsible solution and a set of tests that check the solution is correct. They are there for your own learning, after you have tried the project yourself. You will learn how to read them when you get to your first project with a solution, Average of five numbers. There is nothing to study now.