ProgrammingEasyTCS NQT · Wipro pattern
What is printed?
What is printed?
x = [1, 2, 3] x.append([4, 5]) print(len(x))
- A. 3
- B. 4
- C. 5
- D. 6
Correct answer: B. 4
append adds its argument as ONE element, so the list becomes [1, 2, 3, [4, 5]] with length 4. extend([4, 5]) would have given 5.
More Python Programming questions
- What is printed? python print(2 3 2)
- What is printed? python print(-7 // 2, -7 % 2)
- What is printed? python a = [1, 2, 3] b = a b += [4] print(a)
- What is printed? python print(bool("False"), bool(""), bool(0.0))
- What is printed? python nums = [3, 1, 2] print(nums.sort())
- What is printed? python print([x x for x in range(5) if x % 2])