Lists · Class 11 · CBSE · Science Computer Science
What is printed by the following Python code? values = [5, 10, 15, 20, 25]; print(values[1:4])
Practice question from Lists (Class 11 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.
easy · MCQ · Q-CB01B3
What is printed by the following Python code? values = [5, 10, 15, 20, 25]; print(values[1:4])
- A.[5, 10, 15]
- B.[10, 15, 20]Correct answer
- C.[10, 15, 20, 25]
- D.[15, 20]
Solution
The slice values[1:4] starts at index 1 and stops before index 4. Therefore, it includes 10, 15, and 20.
More from Lists
- What is the value of nums after executing nums = [2, 4, 6]; nums.insert(1, 3)?
- Explain the difference between append() and extend() in Python lists, using the following statements: x = [1, 2]; x.append([3, 4]) and y =…
- What is printed by the following Python code? a = [10, 20, 30]; b = a; c = a[:]; b[1] = 99; c.append(40); print(a, c)
- What is the output of the following Python code? numbers = [3, 1, 2]; result = numbers.sort(); print(result, numbers)
Practise more Computer Science
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed