Bird
Raised Fist0

The following code gives an error. What is the problem?

medium📝 Debug Q6 of Q15
Python - Standard Library Usage
The following code gives an error. What is the problem?
import math
print(sqrt(25))
Asqrt function does not exist
Bsqrt function is not imported directly
Cmath module is not imported
DSyntax error in print statement
Step-by-Step Solution
Solution:
  1. Step 1: Check how sqrt is called

    sqrt is called without prefix, but only math module was imported.
  2. Step 2: Understand import behavior

    To use sqrt directly, it must be imported specifically or called as math.sqrt.
  3. Final Answer:

    sqrt function is not imported directly -> Option B
  4. Quick Check:

    Use math.sqrt or from math import sqrt [OK]
Quick Trick: Call sqrt as math.sqrt or import it directly [OK]
Common Mistakes:
MISTAKES
  • Calling sqrt without math prefix
  • Assuming all functions import automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes