CodeMIRAI
0 XP

Python Programming

Learn Python from your very first line to object-oriented programming, one small topic at a time. Every example runs in your browser, so you can change it and see what happens.

  • 10 modules
  • 64 lessons
  • 353 runnable examples
  • Beginner to advanced
01

Getting started

What Python is, your first program, and how Python reads your code.

  1. Introduction to Python
  2. Your first program
  3. Syntax and indentation
  4. Comments
  5. Variables
  6. Data types
  7. Numbers
  8. Type conversion
  9. Getting input from the user
  10. Printing with f-strings
02

Strings

Working with text: slicing, methods and formatting.

  1. Strings
  2. Indexing and slicing
  3. String methods
  4. Escape characters and raw strings
03

Decisions

Operators, booleans, and making your program choose.

  1. Arithmetic operators
  2. Comparison and logical operators
  3. Booleans and truthiness
  4. if, elif and else
  5. The match statement
04

Loops

Repeating work without repeating code.

  1. while loops
  2. for loops
  3. The range() function
  4. break, continue and loop else
  5. Nested loops
05

Collections

Lists, tuples, sets and dictionaries.

  1. Lists
  2. List methods
  3. List comprehensions
  4. Tuples
  5. Sets
  6. Dictionaries
  7. Looping over dictionaries
  8. Nested collections
06

Functions

Packaging code into reusable pieces.

  1. Defining functions
  2. Parameters and arguments
  3. Return values
  4. Default and keyword arguments
  5. *args and **kwargs
  6. Variable scope
  7. Lambda functions
  8. Recursion
  9. map, filter and sorted
07

Errors and files

Handling what goes wrong, and keeping data in files.

  1. Exceptions and try/except
  2. Raising your own exceptions
  3. Reading and writing files
  4. The with statement
08

Modules and the standard library

Using code that already exists.

  1. Modules and import
  2. math and random
  3. Dates and times
  4. Working with JSON
  5. Regular expressions
  6. Counter and defaultdict
09

Object-oriented Python

Modelling things with classes.

  1. Classes and objects
  2. __init__ and self
  3. Methods
  4. Inheritance
  5. Special (dunder) methods
  6. Properties and encapsulation
  7. Dataclasses
10

Going further

The features that make Python code Pythonic.

  1. Iterators
  2. Generators
  3. Decorators
  4. Writing context managers
  5. Type hints
  6. Dict and set comprehensions