ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(bool(range(0)), bool(range(1)), bool({0: 0}))- A. False True True
- B. True True True
- C. False False True
- D. False True False
Correct answer: A. False True True
An empty range is falsy, a range with one element is truthy, and a non-empty dict is truthy whatever its values are.
More Python Programming questions
- What is printed? python print(sorted([True, 0, 2, False]))
- What is printed? python print(7 // 2 2, 7 / 2 2, 2 3 2)
- What is printed? python print([1, 2] < [1, 3], [1, 2] < [1], 'b' > 'abc')
- 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'}))