ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(0 == False, 0 is False, '' == None)
- A. True True False
- B. False False False
- C. True False True
- D. True False False
Correct answer: D. True False False
False equals 0 by value, but the two are different objects, so the identity test fails. An empty string is never equal to None.
More Python Programming questions
- What is printed? python print(any(x > 2 for x in [1, 2, 3]), next(x for x in [1, 2, 3] if x > 1))
- What is printed? python print(list(range(5, 0, -2)), list(range(0)), range(3)[1:])
- What is printed? python print('x'.join('abc'), 'abc'.join('x'))
- What is printed? python print(True + True, 3 True, 'ab' True)
- What is printed? python print('%.3e' % 12345.678)
- What is printed? python print(sorted([3, 1, 2], reverse=True) == [3, 2, 1], [3, 1, 2][::-1])