Python Quest

Track 10 · Lesson 6 of 12

Writing your own modules

Split a program into several .py files, import your own modules, and understand what module-level code does and when it runs.

About 40 minIntermediate4 exercises

You will be able to

  • Explain why larger programs are split into modules, and decide what belongs in each file
  • Import functions and constants from your own .py files in the same folder
  • Predict when module-level code runs and how module state is shared
  • Avoid name clashes such as shadowing a module or copying a value that later changes

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.