ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
try:
print(list(zip([1, 2], [3], strict=True)))
except ValueError:
print('strict')- A. [(1, 3)]
- B. [(1, 3), (2, None)]
- C. strict
- D. [(1, 3), (2, 3)]
Correct answer: C. strict
zip with strict=True, available from Python 3.10, raises ValueError when the inputs have different lengths. Without strict, zip silently stops at the shorter input.
More Python Programming questions
- What is printed? python print(round(1234, -2), round(1250, -2), round(1350, -2))
- What is printed? python def lcsub(a, b): best = end = 0 dp = [[0] (len(b) + 1) for in range(len(a) + 1)] for i in range(1, len(a) + 1)…
- A solution must decide whether a number n up to 10^12 is prime within about one second in CPython. Which approach is correct and fast…
- What is printed? python d = {'a': 1, 'b': 2} print(d.popitem(), d)
- What is printed? python print('{0}{1}{0}'.format('x', 'y'))
- What is printed? python print(list(filter(None, [0, '', [], [0], None])))