Modules and Imports
LockedLesson 15 of 60 · Architecture · Medium
Mastery0% of 85%
Up next: Variables and Types (~7 min) →Finish these first:Functions →Or pass the tests below to unlock it now.
1
The big idea
Any .py file is a module; a directory with init.py is a package. Avoid circular imports; keep import-time side effects minimal.
Think of it like this: Think of software architecture like modular LEGO sub-assemblies: small, well-named functions and interfaces snap together cleanly without tangling internal wiring.
Key words (tap to learn):
2
Read the lesson
Any .py file is a module; a directory with __init__.py is a package.
import math
from collections import deque
import numpy as np # alias
if __name__ == "__main__":
main()
Avoid circular imports; keep import-time side effects minimal.
3
Quick check
Before writing code: What should `hypotenuse(3,4)` return when your implementation of Modules and Imports is working?
4
2 sample tests, 1 hiddenYour challenge
Write hypotenuse(a, b) using math from the standard library.
Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)
Compare with another language
See how Python compares side-by-side with Java.
Visual walkthrough
A diagram, a step-by-step animation, and short captions for Modules and Imports.
Mastery0%
Learn this first
- FunctionsNot yet
Opens up next
This is the last lesson in this branch.