निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
print(bool(0), bool(3.14159), bool(3), bool(1.0+1j))
A
True True False True
B
False True False True
C
False False False True
D
False True True True
Explanation
Let's break down the code:
print(bool(0), bool(3.14159), bool(3), bool(1.0+1j))
Explanation:
bool(0): In Python,0is considered a falsy value, sobool(0)isFalse.bool(3.14159): Any non-zero number (including floats like3.14159) is considered truthy, sobool(3.14159)isTrue.bool(3): Similarly, any non-zero integer is considered truthy, sobool(3)isTrue.bool(1.0 + 1j): A non-zero complex number (like1.0 + 1j) is also considered truthy, sobool(1.0 + 1j)isTrue.
Output:
(D) False True True True
Correct Answer: D) False True True True