निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
What will be the output of the following Python code?
if (9 < 0) and (0 < -9):
print("hello")
elif (9 > 0) or False:
print("good")
else:
print("bad")
A)
B)
C)
D)
Explanation:
Sure! Let's break it down:
-
First condition:
(9 < 0) and (0 < -9)
9 < 0
is False.0 < -9
is also False.- So, the entire condition is False.
-
Second condition:
(9 > 0) or False
9 > 0
is True.False
is False.- But since it's an
or
condition, if either part is true, the result is True.
-
Since the second condition is True, the output will be
"good"
, and it skips theelse
part.
Answer: (C) good.