ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(all([]), any([]), all([0, 1]), any([0, '']))
- A. False False False False
- B. True True False True
- C. True False False False
- D. True False True False
Correct answer: C. True False False False
all of an empty input is True and any of an empty input is False. Both arguments of all([0, 1]) must be true, and any([0, '']) finds no truthy value.
More Python Programming questions
- What is printed? python print([3, 1].sort() or 'x', sorted([3, 1]) == [1, 3])
- What is printed? python try: try: 1 / 0 except ZeroDivisionError: raise ValueError('bad') except ValueError as e…
- What is printed? python print(sorted([(1, 2), (1,), (0, 9, 9)]))
- What is printed? python print('abcabc'.find('c', 3, 5), 'abcabc'.rfind('a', 0, 4))
- What is printed? python d = {'a': {'b': 1}} print(d.get('a', {}).get('c', 0), d.get('x', {}).get('b'), d['a'].get('b'))
- What is printed? python import math def ndiv(n): c = 0 for i in range(1, math.isqrt(n) + 1): if n % i == 0: c += 1 if i i == n else 2…