ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
x = [1, 2, 3] del x[::2] print(x)
- A. [1, 3]
- B. [1, 2]
- C. [2]
- D. [3]
Correct answer: C. [2]
The extended slice ::2 selects indices 0 and 2, and deleting them leaves only the item at index 1.
More Python Programming questions
- What is printed? python print(max(map(len, ['aa', 'b', 'ccc'])))
- What is printed? python print(bool(range(0)), bool(range(1)), bool({0: 0}))
- What is printed? python print(sorted([True, 0, 2, False]))
- What is printed? python print(7 // 2 2, 7 / 2 2, 2 3 2)
- What is printed? python print([1, 2] < [1, 3], [1, 2] < [1], 'b' > 'abc')
- What is printed? python print(isinstance([], list) and isinstance((), tuple), type([]) == list)