आइए निम्नलिखित पायथन कोड पर विचार करें, इस कोड का आउटपुट है
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
TRUE
B
FALSE
C
None
D
Error
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 = Trueb = Falsec = False
-
Condition in the
ifstatement:- The expression
a or b and cinvolves both the logicalorandandoperators. - Operator Precedence: In Python,
andhas higher precedence thanor. So,b and cis evaluated first.
- The expression
-
Evaluate
b and c:b and cevaluates 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 theifblock is executed, so"TRUE"is printed.
- Since the condition evaluates to
Answer:
(A) TRUE
if a or b and c में or की वजह से यदि a (True) है, तो पूरा एक्सप्रेशन True हो जाता है।
Correct Answer: A) TRUE