A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 50 companion flashcards using spaced repetition.
Python is a high-level, interpreted programming language renowned for its readability and simplicity. Created by Guido van Rossum with the first version released in 1991, Python wa...
Variables in Python are names that reference objects storing data. They are created automatically on first assignment, as in x = 5, and because Python uses dynamic typing, the type...
Python's control flow begins with the if statement, written as if condition: followed by an indented block. The condition is evaluated for truthiness; in Python, non-empty and non-...
Functions are defined using the def keyword, followed by the function name, parameters in parentheses, and a colon, as in def function_name(parameters):. The indented body contains...
Lists are mutable, ordered sequences defined with square brackets, such as mylist = [1, 2, 3]. You access elements by index using mylist[0] for the first element, and negative indi...
Python supports object-oriented programming through classes. You define a class with the class keyword, like class MyClass:, followed by indented methods. Instances are created by...
Python's modular system allows you to organize and reuse code across files and projects. You can import a module with import module and access its functions as module.func, or brin...