निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
What will be the output of the following Python code ?
from math import factorial
print(math.sqrt(25))
A)
B)
C)
D)
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))