आइए निम्नलिखित पायथन कोड पर विचार करें, इस कोड का आउटपुट है
Let consider the following Python code. The output of this code is ____
a = True
b = False
c = False
if a or b and c:
print("TRUE")
else:
print("FALSE")
A)
B)
C)
D)
Explanation:
Let's analyze the given Python code:
a = True
b = False
c = False
if a or b and c:
print("TRUE")
else:
print("FALSE")
Step-by-Step Explanation:
-
Variables:
a = True
b = False
c = False
-
Condition in the
if
statement:- The expression
a or b and c
involves both the logicalor
andand
operators. - Operator Precedence: In Python,
and
has higher precedence thanor
. So,b and c
is evaluated first.
- The expression
-
Evaluate
b and c
:b and c
evaluates asFalse and False
, which isFalse
.
-
Evaluate
a or (b and c)
:- Now the condition becomes
a or False
, which isTrue or False
, which isTrue
.
- Now the condition becomes
-
Result:
- Since the condition evaluates to
True
, the code inside theif
block is executed, so"TRUE"
is printed.
- Since the condition evaluates to
Answer:
(A) TRUE