Python Quest

Track 5 · Lesson 10 of 12

Pure functions and side effects

Write predictable functions that depend only on their arguments, avoid surprising changes to the caller's lists, and check functions with assert.

About 35 minIntermediate4 exercises

You will be able to

  • Define a pure function and name the common kinds of side effect
  • Explain why changing a list argument inside a function also changes the caller's list
  • Return a new list instead of modifying the one passed in
  • Check a function's behaviour with assert statements

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.