ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(any([]) or all([]) and 'x')
- A. False
- B. None
- C. x
- D. True
Correct answer: C. x
'and' binds tighter than 'or'. any([]) is False, so the value comes from all([]) and 'x'. all([]) is True, so the result is 'x'.
More Python Programming questions
- What is printed? python s = 'hello' print(s[1:-1][::-1], s[-1:0:-2])
- What is printed? python d = {} d.setdefault('k', []).append(1) d.setdefault('k', []).append(2) print(d)
- What is printed? python print(1 / 3 + 1 / 3 + 1 / 3 == 1.0, 0.1 + 0.7)
- What is printed? python print(sorted([(-1, 'b'), (-1, 'a'), (0, 'c')]), max([(1, 'z'), (1, 'a')]))
- What is printed? python x = 0 for i in range(5): x += i if i % 2 else -i print(x)
- What is printed? python it = iter([3, 1, 0, 5, 0]) out = [] for x in iter(lambda: next(it), 0): out.append(x) print(out, list(it))