Learn Python.

Write your first line of Python, then work your way up to data processing, asynchronous code, and a tested capstone project.

Course overview

Level
Beginner to advanced
Curriculum
6 modules · 24 lessons
Practice
Real Python in your browser
Prerequisites
None
Your progress0 of 24 lessons complete

Curriculum

Follow the modules in order or jump to a topic you want to practice.

Beginner

Python foundations

Write your first program and learn how Python handles values, text, and decisions.

  1. Hello, worldWrite a line of Python and see what it does.5 min
  2. Variables and numbersName a value and use it in arithmetic.8 min
  3. Work with textSlice, clean, and format strings.8 min
  4. Make decisionsUse conditions to select a branch.9 min

Beginner

Loops and collections

Store groups of values, repeat work, and transform collections.

  1. Lists and tuplesCollect values in order and access them by position.9 min
  2. Repeat with loopsUse for, while, and range to repeat a task.10 min
  3. Dictionaries and setsLook up values by key and find unique items.10 min
  4. Transform a listFilter and transform values with a comprehension.9 min

Intermediate

Reusable programs

Break programs into functions, use the standard library, and handle errors.

  1. Write a functionGive a block of code a name, inputs, and a return value.10 min
  2. Scope and argumentsUse local names, defaults, and keyword arguments.11 min
  3. Modules and importsReuse code from the Python standard library.11 min
  4. Handle exceptionsRecover from expected errors with try and except.11 min

Intermediate

Work with data

Read files, process structured data, and build a reading log.

  1. Read and write filesOpen text files and process them one line at a time.12 min
  2. Read JSON and CSVTurn structured text into dictionaries and rows.12 min
  3. Classes and data classesKeep related values and behavior together.14 min
  4. Project · Reading logSummarize a small JSON reading log.20 min

Advanced

Advanced Python

Control how work is yielded, wrapped, cleaned up, and scheduled.

  1. Iterators and generatorsProduce values on demand with yield.14 min
  2. Closures and decoratorsWrap a function and keep access to the original.16 min
  3. Context managersPair setup and cleanup with a with block.15 min
  4. Async and concurrent workCoordinate independent work while it waits.16 min

Advanced

Build with confidence

Annotate, test, and improve your code, then put it together in a capstone.

  1. Type hintsDescribe the values a function accepts and returns.13 min
  2. Test your codeCheck normal examples, boundaries, and invalid input.15 min
  3. Reason about performanceChoose a data structure based on the work you need to do.15 min
  4. Capstone · Study trackerBuild and test a CSV report from start to finish.30 min