Bird
0
0

Find the error in this code:

medium📝 Debug Q6 of 15
Python - Modules and Code Organization
Find the error in this code:
import math
print(sqrt(25))
ANo error, code runs fine
Bsqrt is not defined without math prefix
Cprint statement is incorrect
Dmath module cannot be imported
Step-by-Step Solution
Solution:
  1. Step 1: Check how sqrt is called

    The function sqrt belongs to math module, so it must be called as math.sqrt.
  2. Step 2: Identify the error

    Calling sqrt directly without prefix causes a NameError because sqrt is not defined in the current scope.
  3. Final Answer:

    sqrt is not defined without math prefix -> Option B
  4. Quick Check:

    Module function call needs prefix = sqrt undefined error [OK]
Quick Trick: Use module_name.function() to call functions [OK]
Common Mistakes:
  • Calling module functions without prefix
  • Assuming import fails
  • Misunderstanding print syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes