Bird
Raised Fist0

Why does this code cause an error?

medium📝 Debug Q7 of Q15
Python - Modules and Code Organization
Why does this code cause an error?
from math import sqrt
from math import sqrt
AYou cannot import the same function twice.
BRepeated imports cause a syntax error.
CYou must import the whole module once only.
DRepeated imports are allowed and cause no error.
Step-by-Step Solution
Solution:
  1. Step 1: Understand repeated import behavior

    Python allows repeated imports of the same function without error.
  2. Step 2: Confirm no syntax or runtime error occurs

    Repeated imports simply reuse the cached module and do not cause errors.
  3. Final Answer:

    Repeated imports are allowed and cause no error. -> Option D
  4. Quick Check:

    Repeated imports allowed, no error [OK]
Quick Trick: Repeated imports do not cause errors [OK]
Common Mistakes:
MISTAKES
  • Assuming repeated imports cause syntax errors
  • Thinking imports must be unique
  • Confusing import with variable assignment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes