निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
a = 15
b = 6
print(a and b)
print(a or b) A
True True
B
False False
C
6 15
D
15 6
Explanation
Let's break down the code and the logic behind it:
a = 15
b = 6
print(a and b)
print(a or b)
Explanation:
-
a and b:- In Python, the
andoperator returns the second operand if the first operand is truthy (non-zero). - Since
a = 15(a non-zero value, which is truthy), the result ofa and bisb, which is 6.
- In Python, the
-
a or b:- The
oroperator returns the first truthy operand it encounters. - Since
a = 15is truthy, the result ofa or bisa, which is 15.
- The
Output:
(C) 6 15
Correct Answer: C) 6 15