Python Programming
Learn to program in Python from your first print to classes, recursion, data structures and algorithms, watching every variable and function call as your code runs.
- Level
- Beginner
- Time
- About 70 hours
- Modules
- 9
- Lessons
- 40
- Exercises
- 138
Python is one of the most popular programming languages in the world, and one of the easiest to start with. It is used for websites, data analysis, automation, science and artificial intelligence. This course assumes no experience at all. You begin by printing a single line, and you can step through every program you read, so that you see exactly what the computer does at each moment.
From there you learn how to make decisions, repeat work, organise data and split a program into functions and classes. The last part introduces the data structures and algorithms that every computer science student meets. Each exercise is checked by running your code against hidden tests, so you always know whether it really works.
What you will learn
- Write correct programs using variables, conditions, loops and functions
- Store and process data with lists, dictionaries, sets and tuples
- Handle errors, test code and find bugs methodically
- Design programs with classes and objects
- Use recursion, data structures and basic algorithms, and judge how fast they are
Skills you will gain
- Writing and reading Python programs
- Breaking a problem into functions
- Processing text and structured data
- Testing and debugging
- Analysing the cost of an algorithm
Before you start
- Basic computer skills: using a browser and typing
- School-level arithmetic
- No programming experience is needed
Where it is used
- Automating everyday computer tasks
- Data analysis and machine learning
- Web back ends with frameworks such as Django and Flask
- University programming courses and technical interviews
Modules
Module 1: First programs
What a program is, how Python stores values, how it does arithmetic, and how to read input and show results neatly.
- 1
Your first program
Print text and numbers, write comments, and watch Python run from top to bottom.
- 2
Variables and assignment
Store values in names, update them, and see what Python does at each line.
- 3
Numbers and operators
Add, divide, find remainders and powers, and learn which operator Python works out first.
- 4
Input and type conversion
Read what the user types, turn text into numbers, and print neat results with f-strings.
- 5
Formatting output
Line up columns, round numbers and add separators with f-string format codes.
Module 2: Decisions and loops
How programs choose what to do and repeat work: conditions, for and while loops, and loops inside loops.
- 1
Decisions with if
Compare values and let the program choose a path with if, elif and else.
- 2
Repeating with for loops
Run the same lines many times with for and range(), and watch the loop variable change.
- 3
Repeating with while
Repeat while a condition holds, stop early with break, and avoid loops that never end.
- 4
Nested loops
Put a loop inside a loop to build grids, combine choices, and see how break affects only the inner loop.
Module 3: Strings and lists
Working with sequences of characters and sequences of values, and how Python's references behave.
- 1
Working with strings
Index, slice and loop over text, and use string methods such as upper() and replace().
- 2
Lists
Store many values in one list, change it, loop over it, and see why two names can share one list.
- 3
enumerate and zip
Loop with a counter using enumerate, and walk through two lists side by side with zip.
- 4
Lists of lists
Store tables and game boards as nested lists, and avoid the trap of copying a row.
Module 4: Functions and modules
Splitting programs into named pieces, understanding the call stack and scope, passing functions around, and reusing the standard library.
- 1
Functions and recursion
Write functions, follow the call stack, and see how a function can call itself.
- 2
More about functions
Default values, keyword arguments, and why a variable inside a function is not the one outside it.
- 3
Functions as values
Store functions in variables and dictionaries, and write small ones with lambda, map and filter.
- 4
Using modules
Import ready-made tools from math and random, and learn the two ways to import.
Module 5: Working with data
Choosing the right collection, counting and grouping, turning raw text into data, and producing values only when needed.
- 1
Tuples and sets
Fixed groups of values, returning several results, and sets that keep each value only once.
- 2
Dictionaries
Look values up by key, count things, and loop over keys and values together.
- 3
List comprehensions
Build a list from a loop in one line, filter it with if, and make dictionaries the same way.
- 4
Processing text data
Split lines and fields, convert them, and turn raw text into numbers you can work with.
- 5
Generators Intermediate
Produce values one at a time with yield, and work with endless sequences without running out of memory.
Module 6: Reliable code
Handling problems you expect, reporting problems clearly, proving that code works, and finding bugs calmly.
- 1
Errors and exceptions
Read error messages, and handle expected problems with try and except.
- 2
Raising your own errors
Signal problems with raise, define your own exception classes, and clean up with finally.
- 3
Testing your code
Check that functions work with assert, think about edge cases, and read a failing test.
- 4
Debugging
Find bugs systematically: reproduce, watch the values, form a guess, and test it.
Module 7: Objects and classes
Designing your own types, reusing them through inheritance, and making them work with Python's built-in operations.
- 1
Classes and objects Intermediate
Design your own types with attributes and methods, and watch objects live in memory.
- 2
Inheritance Intermediate
Build new classes on top of old ones, override methods, and call the parent with super().
- 3
Special methods Intermediate
Make your objects print nicely, compare with ==, add with +, and work with len().
Module 8: Recursion and data structures
Thinking recursively, avoiding repeated work, and building the classic structures that the rest of computer science is made of.
- 1
Recursion in practice Intermediate
Recursive sums, fast powers and the Tower of Hanoi, with every call visible on the stack.
- 2
Memoization Intermediate
Remember answers you have already computed, and turn slow recursion into fast recursion.
- 3
Stacks and queues Intermediate
Last in, first out and first in, first out: two ways to line up work, and where each is used.
- 4
Linked lists Intermediate
Chain objects together with references, walk the chain, insert in the middle, and reverse it.
- 5
Binary trees Intermediate
Build trees of nodes with left and right children, and solve tree problems with recursion.
Module 9: Algorithms and projects
Measuring how fast code is, sorting and searching, useful patterns for lists, and two complete programs that bring the course together.
- 1
How fast is your code? Intermediate
Count the steps a program takes, compare linear and binary search, and meet O(n) and O(n²).
- 2
Sorting algorithms Intermediate
Watch bubble sort and selection sort move values, then sort anything with sorted() and a key.
- 3
Two pointers and sliding windows Intermediate
Solve list problems in one pass by moving two positions through the data.
- 4
Project: a grade book Intermediate
Combine dictionaries, functions, loops and formatting into one small, complete program.
- 5
Project: a shop inventory Intermediate
Design a small class around a dictionary, with methods that keep the stock correct.
- 6
What comes next
Review what you have learned, try one last classic program, and choose your next course.
Projects
- A budget tracker Build a program that keeps track of income and spending from typed commands, and gives a clear report by category.
- A text adventure Build a small game in which the player moves between rooms, picks up items and has to solve a simple goal, all through typed commands.
What to learn next
- Data Structures Lists, stacks, queues, trees, heaps, hash tables and graphs, built in C node by node, with every pointer drawn.
- Algorithms Searching, sorting, recursion, greedy choices, dynamic programming and graph algorithms, with the cost of each one counted.
- Structured Programming in C C as universities teach it: types, loops, arrays, strings, functions, pointers, structs and malloc, with every byte of memory on screen.