Python
BasicAdvancedFrom your first line of Python through functions and collections to comprehensions, generators, the standard library, files and object-oriented programming.
10
modules
25
lessons
25
runnable exercises
Sign in to begin →Sign in, then straight into the first lesson.
Course contents
01Getting startedBasic
Hello, Python
Write and run your first Python program in a live sandbox.
Variables and types
Give values names, and meet Python’s basic types.
02Working with dataBasic
Numbers and math
Use Python as a calculator, and know int from float.
Strings
Build and inspect text with concatenation and f-strings.
String methods and slicing
Change and inspect text with built-in methods, and slice it.
03Logic and repetitionBasic
Making decisions
Branch your program with booleans and if / elif / else.
Repeating with loops
Repeat work with for and while, and build up a result.
Controlling loops
Skip an item with continue, leave early with break.
04FunctionsBasic
Writing functions
Package a block of work under a name and reuse it.
Parameters and return
Pass values in with parameters, get a value back with return.
Flexible arguments
Default values, keyword arguments, and taking any number of them.
Scope and lambdas
Where names live, and one-line throwaway functions.
05CollectionsBasic
Lists
Hold many values in order, and loop over them.
Tuples
Ordered collections that cannot be changed after they are made.
Dictionaries
Store key → value pairs and look values up by name.
Sets
Unordered collections of unique items, and the maths on them.
06Robust codeAdvanced
Handling errors
Catch failures with try / except instead of crashing.
Raising exceptions
Signal errors yourself, and clean up with finally.
07Comprehensions and iterationAdvanced
Comprehensions
Build a list, dict or set from another in a single expression.
Iterators and generators
How for loops work, and producing values lazily with yield.
08Modules and the standard libraryAdvanced
Modules and imports
Reuse code from other files and packages with import.
A standard-library tour
A quick look at math, random, datetime and json.
09FilesAdvanced
Reading and writing files
Save data to a file and read it back with open().
10Object-oriented PythonAdvanced
Classes and objects
Bundle data and behaviour together with your own types.
Inheritance
Build a new class on top of an existing one.
Ready when you are.
Opening a lesson takes an account. Nothing to install.