Practice Slicing a List - 20.4 | 20. LIST – Python Data Structures | CBSE 9 AI (Artificial Intelligence)
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Slicing a List

20.4 - Slicing a List

Enroll to start learning

You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

What is the output of fruits[0:2] for the list fruits = ['apple', 'banana', 'mango', 'orange']?

💡 Hint: Look closely at the starting and ending indices.

Question 2 Easy

If fruits = ['apple', 'banana', 'mango', 'orange'], what does fruits[:2] return?

💡 Hint: Remember ':' means from the beginning up to the index specified.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What will fruits[0:3] return for the list fruits = ['apple', 'banana', 'mango', 'orange']?

['apple'
'banana']
['apple'
'banana'
'mango']
['banana'
'mango'
'orange']

💡 Hint: Think about the inclusive start and exclusive end of the range.

Question 2

If fruits[1:] is executed, what will it return?

True
False

💡 Hint: What does omitting the end index signify?

2 more questions available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

You have a list of cities: cities = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix']. Write a code snippet that uses slicing to return ['Chicago', 'Houston', 'Phoenix'].

💡 Hint: Think about how to access the elements starting from the index of 'Chicago'.

Challenge 2 Hard

Given colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'], create a new list with just the warm colors: ['red', 'orange', 'yellow']. How would you slice for this?

💡 Hint: Identify the starting point and how many colors fall under 'warm'.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.