Question 5
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
import math
math = 3.14 # "the value of pi"
print(math.sqrt(4))
- A It prints 2.0
- B AttributeError: the name math now refers to a float, which has no sqrt; use another variable name Correct
- C ImportError
- D TypeError
Correct Answer: Option B
A module name is an ordinary variable and can be rebound by accident.
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!