ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
t = (1, 2) t += (3,) print(t, len(t))
- A. (1, 2) 2
- B. (1, 2, 3) 3
- C. (1, 2, 3) 2
- D. [1, 2, 4] 3
Correct answer: B. (1, 2, 3) 3
Tuples are immutable, so += builds a new tuple and rebinds t. The new tuple has three items.
More Python Programming questions
- What is printed? python print(abs(-0), abs(-2.5), -(-3))
- What is printed? python print(hex(255), oct(8), bin(-5))
- What is printed? python print(chr(0x41), ord('n'))
- What is printed? python from collections import Counter a = [1, 1, 2, 3, 3] c = Counter(a) print(sum(c[x] c[4 - x] for x in c))
- What is printed? python def nlis(a): n = len(a) L = [1] n C = [1] n for i in range(n): for j in range(i): if a[j] < a[i]: if L[j] + 1 >…
- What is printed? python print(bin(29 ^ 15).count('1'))