Question discussion

What is the output of the following Python code?print(1 < 2 < 3, 1 < 3 < 2, not 1 == 2 or 3, 2 ** -1)

1901Medium DSSSB TGT Computer Science 0 replies

What is the output of the following Python code?

print(1 < 2 < 3, 1 < 3 < 2, not 1 == 2 or 3, 2 ** -1)
  • ATrue True 3 0.5
  • BTrue False True 0.5
  • CTrue False 3 0.5
  • DTrue False True -2
Correct answer: B

Explanation

Chained comparisons give True and False; (not (1 == 2)) is True so "True or 3" is True; 2 ** -1 equals 0.5.

Discussion 0

Nobody has replied yet. Start the discussion!