Python Quest

Track 5 · Lesson 8 of 12

Decomposition: building programs from functions

Break a problem into small functions that each do one job, combine them, and organise the program around a main() function.

About 40 minIntermediate4 exercises

You will be able to

  • Break a task into steps and give each step its own function
  • Write functions that call other functions and pass results between them
  • Organise a program with a main() function and the if __name__ == "__main__": guard
  • Refactor a long block of code into smaller, testable functions without changing its behaviour

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.