Python Programming - Operators - Discussion

Discussion Forum : Operators - General Questions (Q.No. 11)
11.
What is the output of the following code?
x = 10
y = 5
result = x != y and x > y

print(result)
True
False
None
Error
Answer: Option
Explanation:

The != operator is used to check if two values are not equal. In the code, x != y means 10 is not equal to 5, which is True.

The and operator returns True only if both expressions are True.

So, the expression x != y and x > y becomes True and True, which evaluates to True.

Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.