Explore structured python programming courses, solved problems, simulations and Python activities.
Real programs are made of the small ideas that you already know, put together. In this course you plan and build three programs: a guessing game with a score, a quiz that marks your answers, and a grade book with a report. Each project starts with a plan and a table of expected answers, is built in small steps, keeps the thinking in small functions so that it can be tested, and ends with ideas for you to extend. A last lesson gives a checklist for finding the fault in your own programs, and shows where to go after the Foundations. The practice tests the functions of each project on many cases and tells you which ones fail.
You have used functions made by others: print(), len(), range(). Now you write your own. A function is a group of lines with a name, so that you write them once and use them as often as you like. In this course you define and call a function, give it values to work with, get an answer back with return, set default values, make functions that answer yes or no, and let one function use another. You learn where a variable lives and why a variable made inside a function is not known outside it, and how to test a function with a table of cases. A toolbox of functions is the project at the end. The practice runs your functions on many inputs and tells you which ones fail.
So far, one variable held one value. A class has thirty marks, a shop has a hundred prices, and you cannot make a hundred variables. A list holds many values in one variable. In this course you make lists, read them by position and by slice, add, remove, replace and sort items, go through a list with a loop, and find totals, averages, the biggest and the smallest. You learn why a copy of a list is not what you expect, and how to make a table with a list inside a list. A marks tracker is the project at the end. The practice runs your code on real lists and tells you which results are wrong.
A computer does not get tired. A loop lets it repeat the same lines a hundred, a thousand or a million times, while you type them only once. In this course you learn the for loop, the range() function that makes a row of numbers, how a loop builds an answer such as a sum, a count or a factorial, and how to put one loop inside another to make tables and patterns. A project at the end prints a multiplication table book. The practice runs your loops and tells you which results are wrong.
A for loop is for a number of rounds that you know. A while loop is for the cases where you do not know: keep saving until there is enough, keep asking until the answer is right, keep going until something happens. In this course you write while loops, learn what makes them stop, leave a loop early with break, skip a round with continue, and ask the user again and again. A lesson on the loops that go wrong shows how to choose between for and while, and how to find an endless loop and a loop that is off by one. A guessing game with hints and a limit of tries is the project. The practice runs your loops and tells you which results are wrong.
Until now, a program did every line, one after the other. In this course it learns to choose. You compare values, run some lines only when a condition is True, choose between two and then between many possibilities, and learn how to test every branch so that the program is right at the edges, where mistakes hide. You finish with a ticket office program. The practice runs your decisions on many test values and tells you which ones fail.
One simple condition is often not enough. A person can enter a club if they are old enough and have a ticket. A shop gives a discount to students or to senior citizens. In this course you combine conditions with and, or and not, check a range, ask whether a value is inside a group with in, and put one decision inside another. You learn to prove a combined condition with a truth table, and to simplify a condition with the rule of not. A club entry program at the end uses everything. The practice tests your conditions on many cases and tells you which ones fail.
A step-by-step guide to putting Python on your own computer. You check what you need, install it on Windows, macOS or Linux, write a program as a file, and run it from an editor and from a terminal. A last lesson lists the problems that most beginners meet, with the way out of each one, and shows what to do next. You can skip this chapter and still follow the rest of the book.
Text in Python is called a string. In this course you count the letters, pick out single letters and pieces, change the case, clean messy text, join and repeat text, put values inside sentences with f-strings, ask questions about text, and search inside it. You finish with a name tag maker and a small text analyser. Every lesson has practice that checks your answers.
A program becomes useful when it can listen. In this course you ask the user a question with input(), you learn why the answer is always text and how to turn it into a number, and you write small programs that ask, calculate and answer: a temperature converter, a tip calculator, a unit converter and a bill splitter. The practice checks your answers for you, and gives the program its answers, so you do not have to type them.
Python can add, subtract, multiply and divide, and it has special signs for whole-number division, the remainder and powers. In this course you use them to solve everyday problems, learn which sign Python does first, meet the number tools round, abs and divmod, and finish with two small projects: a machine that gives change, and a program that turns seconds into a clock time. Every lesson has practice that checks your answers.
Every program needs a place to keep what it knows: a score, a name, a price. In this course you learn to keep values in variables, to change them step by step, to follow a program by hand, to tell the four kinds of value apart, to choose names that other people can read, and to put it all together in a small project. Every lesson ends with practice that checks your answers for you.