Bird
0
0

What is wrong with this code?

medium📝 Debug Q14 of 15
Python - Modules and Code Organization
What is wrong with this code?

import math from math import sqrt print(math.sqrt(16))
AYou cannot import the same module twice.
BThe code will cause a NameError.
CThere is no error; the code runs and prints 4.0.
DYou must use only one import style per module.
Step-by-Step Solution
Solution:
  1. Step 1: Check import statements

    Importing the same module twice with different styles is allowed and does not cause error.
  2. Step 2: Verify function call

    Calling math.sqrt(16) works and returns 4.0.
  3. Final Answer:

    There is no error; the code runs and prints 4.0. -> Option C
  4. Quick Check:

    Multiple imports allowed; function call works = D [OK]
Quick Trick: Multiple imports of same module are allowed [OK]
Common Mistakes:
  • Thinking multiple imports cause errors
  • Confusing import styles must be exclusive
  • Expecting NameError from this code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes