LearnFrenzy
Sign in Take a free test

Modules and Packages · Find the Error · Question 2

Error: importing a name the module does not have Answer, explanation & discussion

  • Find the error
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 2 Back to Exercise

The program below stops with an error. Which statement correctly describes the problem?

main.py
from math import square_root
print(square_root(49))
  • A ModuleNotFoundError: math
  • B ImportError: math has no name square_root; the function is sqrt Correct
  • C It prints 7.0
  • D NameError
Correct Answer: Option B

The module is found, but the requested name is not in it, so the error is ImportError ("cannot import name").

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links