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

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skills—perfect for learners of all ages.

Practice Questions

Test your understanding with targeted questions related to the topic.

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.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

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?

Solve 2 more questions and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

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'.

Question 2

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'.

Challenge and get performance evaluation