ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(1 == True == 1.0, 2 > 1 == True, (2 > 1) == True, 1 < 2 == True)
- A. True True False False
- B. True False True False
- C. True True True False
- D. True True True True
Correct answer: C. True True True False
Chained comparisons check each adjacent pair, so 1 == True == 1.0 holds, and 2 > 1 == True holds too. The last one needs 1 < 2 and 2 == True, but 2 is not equal to True.
More Python Programming questions
- What is printed? python print(int(' 0x1f ', 16), int('1e3', 16), float('1e3'))
- What is printed? python from collections import Counter c = Counter(['x', 'y', 'x', 'z', 'y', 'x']) print(c.mostcommon()…
- What is printed? python print(10 % 3 2, 10 % (3 2), (10 % 3) 2, -10 % 3 2)
- What is printed? python print(list(range(10, 0, -3)), list(range(-1, -10, -4)), len(range(0, 10, 3)), range(5)[-1])
- What is printed? python print(len('anb'), len('anb'), len(r'anb'), len('arb'))
- What is printed? python print(8 % -3, -8 % -3, 8 // -3, -8 // -3)