What a Module Is, and the import Statement
Quick answer A module is a file of ready-written, tested Python code; import loads it, and after a plain import every name inside it must be reached through dot notation.
A module is a file of ready-written Python code that you can pull into your own program. Somebody has already written it, tested it and packed it up; you just borrow it. Python ships with dozens of these. Your syllabus names three: math, random and statistics.
A note about your NCERT book, before you get confused. NCERT prints all of this material inside Chapter 7, which is titled "Functions". Most of that chapter teaches you to write your own functions with def and return, along with parameters and scope. The CBSE 2025-26 syllabus for Class 11 (code 083) places all of that in Class 12, not Class 11. Only the module half of NCERT Chapter 7 is examinable for you this year. So when you open the book and find pages on def, do not panic that we have skipped them - they are not yours yet. Everything on this page is.
Why modules exist at all. Suppose there were no math module and you needed a square root. You would have to write the algorithm yourself. Here is the Babylonian method, which starts from a guess and keeps improving it:
# Square root the hard way (Babylonian method)
n = 2
guess = 1.0
for i in range(20):
guess = (guess + n / guess) / 2
print("Hand written :", guess)
# Square root the module way - one line
import math
print("math.sqrt(2) :", math.sqrt(2))
Output:
Hand written : 1.414213562373095
math.sqrt(2) : 1.4142135623730951
Five lines and a loop against one line - and look closely at the last digit. The module's answer is the more accurate of the two, because it hands the job to the processor's own square-root instruction instead of guessing twenty times. That is the whole argument for modules: code that is correct, fast and already tested, which you did not have to write.
Nothing is available until you import it. Run this on its own:
print(sqrt(144))
The last lines of the traceback read:
NameError: name 'sqrt' is not defined
Now add the import and run it again:
import math
print(sqrt(144))
It still fails, with exactly the same message:
NameError: name 'sqrt' is not defined
This trips up almost everybody once. import math brings one new name into your program: math. It does not scatter sqrt, pi, floor and the rest loose in your file. Everything inside has to be reached through the module's name, with a dot:
import math
print(math.sqrt(144))
print(math.pi)
print(type(math))
12.0
3.141592653589793
The dot means "inside". Read math.sqrt as "the sqrt that lives inside math". Notice also that math has a type of its own - module - just as 7 has type int.
Giving a module a nickname. If a module name is long or you use it constantly, import ... as renames it:
import math as m
side = 7
print("Area of square plot :", m.pow(side, 2), "sq m")
print("Diagonal of the plot:", round(m.sqrt(2 * side * side), 2), "m")
Area of square plot : 49.0 sq m
Diagonal of the plot: 9.9 m
After import math as m, the name math does not work - only m does. The nickname replaces the original, it does not sit alongside it, so math.sqrt(4) would raise NameError: name 'math' is not defined.
Seeing what is inside a module. The built-in dir() lists every name a module offers:
import math
print(dir(math)[:8])
print(len(dir(math)))
['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin']
67
Sixty-seven names in one small module on Python 3.13 (the exact count varies a little between versions). You only need the nine your syllabus lists, but dir() is genuinely useful when you are stuck and cannot remember a spelling.
- A module is a file of ready-written Python code; importing it lets you reuse work you did not write, correctly and fast.
- NCERT prints modules inside Chapter 7 ("Functions"), but CBSE places user-defined functions in the Class 12 syllabus - only the module part of that chapter is in your Class 11 course.
- import math adds exactly one name to your program: math. Every item inside must then be written with dot notation, as math.sqrt(144).
- Forgetting the import, or forgetting the dot, both give the same error: NameError: name 'sqrt' is not defined.
- import math as m renames the module - after it, m works and math does not.
