ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(bool(0 or '' or []), bool([[]]), bool([0]), bool(' '.strip()))- A. True True True True
- B. False False True True
- C. False True False True
- D. False True True False
Correct answer: D. False True True False
Each operand in the first expression is falsy, so bool gives False. [[]] is a non-empty list, [0] is non-empty, and ' '.strip() is the empty string, which is False.
More Python Programming questions
- What is printed? python print(round(2.345, 2), round(2.355, 2), round(7.5), round(8.5))
- What is printed? python print(len([x for x in range(3) for y in range(x)]), [x y for x in range(3) for y in (1, 2) if x], sum(1 for i in…
- What is printed? python data = {'a': 1} print(data.get('b', 0) + 1, data.get('a') + 1, 'a' in data, 1 in data.values())
- What is printed? python print(3 in range(5), 5 in range(5), range(0, 6, 2) == range(0, 7, 2), list(range(3, 0, -1)))
- What is printed? python print(10 % 4 == 2, -10 % 4 == 2, 10 // -4, 10 / -4)
- What is printed? python s = 'abcdef' print(s[-2:], s[:-2], s[-10:], s[::-2][0])