A New Journey: The Workshop
Welcome to The Architect's Path! Hoppy has mastered the basic elemental magic. Now, he stands before the Archmage's Workshop.
Here, magic isn't written on just a single sheet of paper. To build complex spells, the Archmage organizes spells into different Scrolls (Files).
Look above the editor! You see another tab next to main.py. That represents another scroll on the workbench.
Using Multiple Scrolls
In this workshop, main.py is your main workbench. But sometimes, we need tools stored elsewhere.
import tools # 1. Grab the scroll named 'tools' tools.hammer() # 2. Use the 'hammer' spell from that scroll
This is called Importing. It keeps our main scroll clean while letting us use powerful external magic!
Your Mission
Click the tools.py tab above the editor to see what spells are hidden inside (just looking, no touching!).
Go back to the main.py tab.
Write code to import tools, then use its hammer tools.hammer() to ring the workshop bell!
Notice anything? The "Visualize" button is gone.
In the Workshop, we focus on Creating Results (Terminal), not watching the mana flow. This is the Architect's way.
Suggested SolutionExpandCollapse
import tools
print("Getting ready...")
tools.hammer()Advanced TipsWant more? Click to expandClick to collapse
F. Bridge to Reality
- Scrolls are known as Modules in Python.
- The Workshop is like a Project or Package.
- In the real world, programmers never write thousands of lines in one file. We split code into different
.pyfiles andimportthem. This is the first step of "Modular Programming"!