ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(len(''), len(' '), len('\t'), ''.isspace())- A. 0 0 1 False
- B. 0 1 1 False
- C. 0 1 1 True
- D. 1 1 1 False
Correct answer: B. 0 1 1 False
The empty string has length 0, while a space and a tab are one character each. isspace on the empty string is False, since it needs at least one whitespace character.
More Python Programming questions
- What is printed? python print(1 + '1' if False else '1' + str(1), '3' 2 + str(4 - 1), int('3' 2) + 4 - 1)
- What is printed? python print(bool(0 or '' or []), bool([[]]), bool([0]), bool(' '.strip()))
- 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)))