Skip to content

Animations ​

Step-by-step animations that show what Python does under the hood: what a variable really is, and in which order an expression is calculated.

Each animation has several scenarios (tabs at the top). A link below opens one scenario in a new tab.

  • Next step: Right arrow or Space. Back: Left arrow. Start: Home. Auto-play: P.
  • file.html#3 opens scenario 3, file.html#3.5 opens scenario 3 at step 5.
  • Scenarios marked advanced go deeper.

English and Bulgarian

Every animation is in English and in Bulgarian. The EN / BG button at the top of an animation switches the language and keeps the current step.

Session 1 - Introduction, syntax, data types and variables ​

Names and objects - a variable is a name bound to an object; assignment, a new value, two names for one object, x = x + 1, dynamic typing, is and ==. 1. A name and an object, 2. A new value, 3. Two names, one object, 4. x = x + 1, 5. Types belong to objects, 6. Several names at once, 7. is and == (advanced)

How an expression is evaluated - the order of operations, step by step, with the table of priorities. 1. Precedence, 2. Brackets, 3. ** and minus, 4. // and %, 5. Chained comparisons, 6. and / or, 7. Mixed types

Session 2 - Conditional statements and loops ​

Loops step by step - the variables, the test and the output of if / elif / else, for, while, break and continue, one line at a time. 1. for with an accumulator, 2. Decisions in a loop, 3. while: repay a loan, 4. break: stop at the first, 5. continue: skip a record, 6. for - else (advanced)

Session 3 - Lists (basics), tuples and sets ​

Lists and references - a list changes in place; two names for one list; copies; sort() and sorted(); tuples that cannot change. 1. A list changes in place, 2. Two names, one list, 3. A copy, 4. sort() and sorted(), 5. A tuple cannot change, 6. A list inside a tuple (advanced)

Session 4 - Functions ​

Function calls step by step - each call gets a frame with its local names; return; local and global names; calls in calls; a list passed to a function. 1. A call and a return, 2. Local and global, 3. UnboundLocalError, 4. A function calls a function, 5. A list passed to a function, 6. A list as a default value (advanced)

Session 6 - Dictionaries ​

Grouping by hand - a dictionary as a lookup table, and as the result of a GROUP BY that grows row by row: a lookup with a default, counting with get, sums with defaultdict, groups of rows in lists, and a join by key. 1. A lookup, 2. Count with get, 3. Sum with defaultdict, 4. Group into lists, 5. The join by key

Created for