ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print([1, 2] < [1, 3], [1, 2] < [1], 'b' > 'abc')
- A. True True True
- B. False False True
- C. True False False
- D. True False True
Correct answer: D. True False True
Lists compare item by item, so [1, 2] is less than [1, 3]. A longer list with the same prefix is larger, and 'b' is greater than 'abc' at the first character.
More Python Programming questions
- What is printed? python print(isinstance([], list) and isinstance((), tuple), type([]) == list)
- What is printed? python print(''.join(sorted('hello', key=lambda c: c in 'aeiou')))
- What is printed? python print(len({(1, 2): 'a', (2, 1): 'b', (1, 2): 'c'}))
- What is printed? python x = 5 def f(): return x x = 6 print(f(), (lambda: x)())
- What is printed? python print(list(range(10))[2:8:3], list(range(10))[::4])
- What is printed? python print(not [] is [], (not []) is [])