ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
x = (1, [2]) x[1].append(3) print(x)
- A. (1, [2, 3])
- B. (1, [2])
- C. (1, [3])
- D. (1, 2, 4)
Correct answer: A. (1, [2, 3])
A tuple cannot be reassigned in place, but the list inside it is mutable, so appending to it changes the tuple's visible contents.
More Python Programming questions
- What is printed? python print(max([1, 5, 3], key=lambda v: -v))
- What is printed? python print(list(map(int, '1 2 3'.split()))[::-1])
- What is printed? python print(f'{7:03d}|{-7:d}|')
- What is printed? python x = 7 print(f'{x=}', f'{x 2 = }', f'{"a"!r:>4}')
- What is printed? python import keyword print(keyword.iskeyword('match'), keyword.issoftkeyword('match'), keyword.iskeyword('None')…
- What is printed? python print({'a': 1} | {'a': 2, 'b': 3}, {'a': 1} | {}, dict(a=1) == {'a': 1})