Bird
Raised Fist0

What does the statement from math import sqrt do in Python?

easy🧠 Conceptual Q11 of Q15
Python - Modules and Code Organization
What does the statement from math import sqrt do in Python?
AIt imports the entire <code>math</code> module.
BIt imports only the <code>sqrt</code> function from the <code>math</code> module.
CIt imports all functions except <code>sqrt</code> from <code>math</code>.
DIt renames the <code>math</code> module to <code>sqrt</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the import syntax

    The syntax from module import item imports only the specified item from the module.
  2. Step 2: Apply to the given statement

    Here, sqrt function is imported from the math module, not the whole module.
  3. Final Answer:

    It imports only the sqrt function from the math module. -> Option B
  4. Quick Check:

    from module import item = import only that item [OK]
Quick Trick: Remember: 'from module import item' imports just that item [OK]
Common Mistakes:
MISTAKES
  • Thinking it imports the whole module
  • Confusing import with renaming
  • Assuming it excludes the named item

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes