CBSE Class 11 Computer Science Chapter 13: Lists, Dictionaries, and Tuples NCERT Solutions
This chapter provides NCERT Solutions for Class 11 Computer Science, focusing on Python's fundamental data structures: Lists, Dictionaries, and Tuples. The solutions cover various aspects of lists, including their types, indexing, slicing, and common methods like `remove()`, `append()`, `extend()`, `count()`, `len()`, `max()`, and `min()`. It also explains how to compare lists and convert sequences. These detailed explanations and step-by-step solutions are designed to help students understand the core concepts of these data structures, enabling them to solve problems effectively and prepare thoroughly for their examinations. The chapter emphasizes practical application and understanding of Python's list manipulation capabilities.
Quick info
| Board | CBSE |
|---|---|
| Class | Class 11 |
| Subject | Computer Science |
| Session | 2026 |
| Language | English |
| Type | NCERT Solutions |
| Chapter | 13. Lists, Dictionaries and Tuples |
Chapter summary
Chapter 13 on Lists, Dictionaries, and Tuples for CBSE Class 11 Computer Science offers NCERT Solutions that delve into Python's sequence data types. It covers the basics of lists, including built-in sequence types, element access via indexing and slicing, and essential methods for manipulation and information retrieval. The solutions explain how to remove elements, compare lists, find lengths, and identify maximum and minimum values. Methods for adding elements and counting occurrences are also detailed. This chapter is crucial for building a strong foundation in data structures for programming.
Learning outcomes
- Identify the different types of built-in sequence types in Python.
- Understand and apply list indexing to access individual elements.
- Utilize list slicing to extract sub-sequences from a list.
- Explain the functionality of various list methods like `remove()`, `append()`, `extend()`, and `count()`.
- Determine the length of a list using the `len()` function.
- Use `max()` and `min()` functions to find the largest and smallest elements in a list.
- Compare elements of two lists using comparison functions.
- Convert sequences like tuples into lists using the `list()` constructor.
Topics covered
Paper topics
- Built-in sequence types in Python
- List indexing
- List slicing
- Removing list elements (`del`, `remove()`)
- List comparison (`cmp()` concept)
- List length (`len()`)
- Finding maximum and minimum elements (`max()`, `min()`)
- Converting sequences to lists (`list()`)
- Appending objects (`append()`)
- Counting element occurrences (`count()`)
- Extending lists (`extend()`)
- Python List Operations
Important topics
- List indexing and slicing
- List manipulation methods (`append`, `extend`, `remove`, `count`)
- Built-in functions for lists (`len`, `max`, `min`)
- Understanding sequence types
- Converting between sequence types
PDF preview
Read page by page below. PDF is streamed from the official NCERT website — no download button on this page.
Questions and Solutions
Question 1
Python offers six distinct built-in types of sequences. These are fundamental data structures used for storing ordered collections of items.
Question 2
#!/usr/bin/python
list1 = ['physics', 'chemistry', 1997, 2000]
list2 = [1, 2, 3, 4, 5, 6, 7]
print "list1[0]", list1[0]
The code initializes two lists, list1 and list2. It then prints the element at index 0 of list1. Since list indices start at 0, list1[0] refers to the first element.
Output:
list1[0]: physics
Question 3
#!/usr/bin/python
list1 = ['physics', 'chemistry', 1997, 2000]
list2 = [1, 2, 3, 4, 5, 6, 7]
print "list2[1:5]", list2[1:5]
This Python code initializes two lists. It then prints a slice of list2, specifically elements from index 1 up to (but not including) index 5. List slicing extracts a portion of the list.
Output:
list2[1:5]: [2, 3, 4, 5]
Question 4
To remove an element from a list in Python, you have a couple of primary options:
- Using the
delstatement: You can remove an element at a specific index usingdel list_name[index]. - Using the
remove()method: This method removes the first occurrence of a specified value from the list. The syntax islist_name.remove(value).
Question 5
cmp(list1, list2) in Python?
The cmp(list1, list2) function (primarily used in Python 2) was used to compare the elements of two lists lexicographically. It returned -1 if list1 < list2, 0 if list1 == list2, and 1 if list1 > list2. In Python 3, direct comparison operators like <, ==, and > are used for list comparison.
Question 6
len(list) in Python?
The built-in function len(list) is used to determine and return the total number of items or elements present in the list. It provides the size of the list.
Question 7
max(list) method.
The built-in function max(list) returns the item from the list that has the highest value. This function works for lists containing comparable elements, such as numbers or strings.
Question 8
min(list) method.
The built-in function min(list) returns the item from the list that has the lowest value. Similar to max(), this function requires the list elements to be comparable.
Question 9
list(seq) in Python?
The list(seq) constructor is used to convert a sequence (such as a tuple, string, or another iterable) into a list. For example, if seq is a tuple, list(seq) will create a new list containing the same elements in the same order.
Question 10
list.append(obj)?
The list.append(obj) method is used to add a single item, referred to as obj, to the very end of the list. It modifies the original list in place.
Question 11
list.count(obj)?
The list.count(obj) method returns the number of times a specified object or value, obj, appears within the list. It counts all occurrences of that value.
Question 12
list.extend(seq).
The list.extend(seq) method is used to append all the items from an iterable sequence (like another list, tuple, or string) to the end of the current list. It effectively adds the contents of seq to the existing list.
Common mistakes
- Incorrectly specifying slice indices, leading to unexpected sub-sequences.
- Confusing the `remove()` method with `pop()` or other deletion methods.
- Misunderstanding the difference between `append()` and `extend()` when adding elements.
- Off-by-one errors when accessing elements by index.
- Assuming `cmp()` function is directly available in Python 3 without using appropriate comparison logic.
Revision tips
- Practice accessing elements using both positive and negative indices.
- Experiment with different slicing parameters to understand their effects.
- Write small Python programs to test each list method described.
- Compare the output of `append()` versus `extend()` with examples.
- Review the purpose of each built-in sequence type and when to use them.
Practice MCQs
Q1. How many built-in types of sequences are available in Python?
Explanation: Python provides six built-in types of sequences, which are fundamental for storing ordered collections of data.
Q2. What will be the output of `list1[0]` if `list1 = ['physics', 'chemistry', 1997, 2000]`?
Explanation: List indices in Python start from 0. Therefore, `list1[0]` refers to the first element, which is 'physics'.
Q3. What does the `list.remove(obj)` method do?
Explanation: The `remove(obj)` method searches for the first occurrence of the value `obj` in the list and removes it.
Q4. Which function returns the total number of items in a list?
Explanation: The built-in `len()` function is used to get the total number of elements present in a list.
Q5. What is the primary use of `list.extend(seq)`?
Explanation: The `extend(seq)` method appends all the elements from an iterable (like another list or tuple) to the current list.
Frequently asked questions
What are the main sequence types in Python covered in this chapter?
This chapter focuses on Lists as a primary sequence type, discussing their properties and operations. While the chapter title mentions Dictionaries and Tuples, the provided solutions specifically detail various aspects of Python Lists.
How do I access elements in a Python list?
You can access elements using their index, which starts from 0 for the first element. For example, `my_list[0]` gets the first element. Negative indices can also be used, where `my_list[-1]` refers to the last element.
What is the difference between `append()` and `extend()` methods for lists?
The `append(obj)` method adds a single object `obj` as one element to the end of the list. The `extend(seq)` method, on the other hand, iterates over its argument `seq` and appends each of its elements to the list.
How can I remove an element from a list?
You can remove an element using the `del` statement with an index, or by using the `remove(obj)` method, which removes the first occurrence of the specified value `obj`.
What is the purpose of `len(list)`?
The `len(list)` function returns the total number of items or elements currently present in the list.
Can these solutions help me prepare for exams?
Yes, these NCERT Solutions provide clear explanations and cover essential concepts and methods related to Python lists, which are frequently tested in computer science exams.
Content reviewed by the NCERT Help team. Editorial Team and update policy
NCERT Solutions PDF PDF on NCERT Help. URL unchanged for search indexing.