Import Syntax
Multiple Choice Easy
Question
What does from math import sqrt do?
Hint
from...import imports specific names.
Explanation
from math import sqrt imports only the sqrt function from the math module, so you can use sqrt(4) directly instead of math.sqrt(4). This is convenient but can cause name conflicts. import math imports the whole module, requiring math.sqrt. from math import * imports everything (discouraged). Choose based on readability and avoiding conflicts.
Related Resources
Related Lessons
- Modules
Learn Python modules.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.