Python Quest

Track 16 · Lesson 3 of 12

Measuring the cost of code

Count the work an algorithm does, describe how it grows with Big-O, and time code honestly.

About 45 minIntermediate4 exercises

You will be able to

  • Count the basic operations a function performs for inputs of different sizes
  • Describe growth as O(1), O(log n), O(n), O(n log n) or O(n²) and recognise each in code
  • Spot hidden loops such as `in` on a list, slicing and `sum()` inside a loop
  • Time code with time.perf_counter and timeit, and interpret the numbers carefully

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.