निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
a = 15
b = 6
print(a and b)
print(a or b)
A)
B)
C)
D)
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
and
operator 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 b
isb
, which is 6.
- In Python, the
-
a or b
:- The
or
operator returns the first truthy operand it encounters. - Since
a = 15
is truthy, the result ofa or b
isa
, which is 15.
- The
Output:
(C) 6 15