निम्नलिखित पायथन कोड का आउटपुट क्या होगा?
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
error
B
hello
C
good
D
bad
Explanation
Sure! Let's break it down:
-
First condition:
(9 < 0) and (0 < -9)9 < 0is False.0 < -9is also False.- So, the entire condition is False.
-
Second condition:
(9 > 0) or False9 > 0is True.Falseis False.- But since it's an
orcondition, if either part is true, the result is True.
-
Since the second condition is True, the output will be
"good", and it skips theelsepart.
Answer: (C) good.
Correct Answer: C) good