We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Modules

It would be a massive pain if we had to fit all of our code into a single file. So, let's organize our code into separate modules.

Since each .py file is a module, we can group related functions, variables, and classes together in a module. Then, other modules can import them using the syntax:

from module_name import my_function
# or import everything: from module_name import *

Constants

Games often have a lot of magic numbers to represent things like player speeds, item costs, and attack damage. We'll use a dedicated module as a place to store those kinds of constant values.

Assignment

  1. SCREEN_WIDTH = 1280
    SCREEN_HEIGHT = 720
    
  2. Screen width: 1280
    Screen height: 720
    

Run and submit the CLI tests.