निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
What will be the output of the following Python code ?
from math import factorial
print(math.sqrt(25))
A
5.0
B
Nothing is printed
C
Error, method sqrt doesn‟t exist in math module
D
Error, the statement should be: print(sqrt(25))
Explanation
The error occurs because only factorial was imported from the math module, not the whole math module. The code tries to use math.sqrt(25), but math is not available.
To fix it, either import the entire math module:
import math
print(math.sqrt(25))
Or import sqrt directly:
from math import sqrt
print(sqrt(25))
Answer:
(D) Error, the statement should be: print(sqrt(25))
Correct Answer: D) Error, the statement should be: print(sqrt(25))