Bird
Raised Fist0

What will be the output of this code?

medium📝 Predict Output Q13 of Q15
Python - Modules and Code Organization
What will be the output of this code?
import math
print(math.sqrt(16))
A4.0
B16
CError: sqrt not found
DNone
Step-by-Step Solution
Solution:
  1. Step 1: Understand the code

    The code imports the math module and calls sqrt(16) which calculates the square root of 16.
  2. Step 2: Calculate the square root

    The square root of 16 is 4.0 (a float), so the print statement outputs 4.0.
  3. Final Answer:

    4.0 -> Option A
  4. Quick Check:

    math.sqrt(16) = 4.0 [OK]
Quick Trick: math.sqrt(16) returns 4.0 [OK]
Common Mistakes:
MISTAKES
  • Expecting integer 4 instead of float 4.0
  • Thinking sqrt is not in math module
  • Forgetting to import math module

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes