Skip to main content
Chapter 9 of 11
NCERT Solutions

Lists — NCERT Solutions

CBSE · Class 11 · Computer Science

NCERT Solutions for Lists, CBSE Class 11 Computer Science: 22 textbook questions solved step by step. Covers Exercise and Programming Problems.

44 questions84 flashcards6 formulas & key relations5 concepts

Interactive on Super Tutor

Studying Lists? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for NCERT solutions and more.

Free trial, no card needed.

22 Questions Solved · 2 Sections

The first 11 solutions are open to read. The other 11 are free with a Super Tutor account.

Exercise

1(i)What will be the output of the following statements?
list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
Show solution

Given: A list list1 = [12,32,65,26,80,10]

Concept: list1.sort() sorts the list in-place in ascending order and modifies the original list.

Working:

  • Original list: [12, 32, 65, 26, 80, 10]
  • After list1.sort(): elements are arranged in ascending order → [10, 12, 26, 32, 65, 80]
  • print(list1) prints the modified list.

Output:

[10, 12, 26, 32, 65, 80]
1(ii)What will be the output of the following statements?
list1 = [12,32,65,26,80,10]
sorted(list1)
print(list1)
Show solution

Given: A list list1 = [12,32,65,26,80,10]

Concept: sorted(list1) returns a new sorted list but does not modify the original list. The result is not stored in any variable, so list1 remains unchanged.

Working:

  • sorted(list1) creates a new sorted list [10, 12, 26, 32, 65, 80] but it is discarded since it is not assigned to any variable.
  • list1 still holds its original values.
  • print(list1) prints the original unmodified list.

Output:

[12, 32, 65, 26, 80, 10]
1(iii)What will be the output of the following statements?
list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]
Show solution

Given: list1 = [1,2,3,4,5,6,7,8,9,10]

Concept: Slicing creates a new list but does not modify the original. Since the results are not printed or assigned, there is no output from these statements.

Working:

  • list1[::-2] → traverses from end to start with step −2-2, giving [10, 8, 6, 4, 2]. But this is not printed or stored.
  • list1[:3] + list1[3:] → [1,2,3] + [4,5,6,7,8,9,10] = [1,2,3,4,5,6,7,8,9,10]. But this is also not printed or stored.

Output:

(No output — neither expression is printed)
1(iv)What will be the output of the following statements?
list1 = [1,2,3,4,5]
list1[len(list1)-1]
Show solution

Given: list1 = [1,2,3,4,5]

Concept: len(list1) returns 5. So list1[len(list1)-1] = list1[4] which is the last element. However, since this expression is not passed to print(), there is no output.

Working:

  • len(list1) = 55
  • list1[5 - 1] = list1[4] = 55
  • The value 55 is computed but not printed.

Output:

(No output — the expression is not printed)

Note: If it were print(list1[len(list1)-1]), the output would be 5.

2Consider the following list myList. What will be the elements of myList after the following two operations:
myList = [10,20,30,40]
i. myList.append([50,60])
ii. myList.extend([80,90])
Show solution

Given: myList = [10, 20, 30, 40]

Concept:

  • append(x) adds x as a single element (even if x is a list) at the end.
  • extend(iterable) adds each element of the iterable individually at the end.

Working:

i. After myList.append([50,60]):

  • [50, 60] is added as a single element (a nested list).
  • myList becomes: [10, 20, 30, 40, [50, 60]]

ii. After myList.extend([80,90]) (applied on the result of step i):

  • 80 and 90 are added individually.
  • myList becomes: [10, 20, 30, 40, [50, 60], 80, 90]

Final Answer:

After append: [10, 20, 30, 40, [50, 60]]
After extend: [10, 20, 30, 40, [50, 60], 80, 90]
3What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
for i in range(0,len(myList)):
if i%2 == 0:
print(myList[i])
Show solution

Given: myList = [1,2,3,4,5,6,7,8,9,10]

Concept: The loop iterates over indices ii from 00 to 99. The condition i % 2 == 0 is true for even indices: 0,2,4,6,80, 2, 4, 6, 8.

Working:

Index iii%2==0i \% 2 == 0?myList[i] printed
0Yes1
1No—
2Yes3
3No—
4Yes5
5No—
6Yes7
7No—
8Yes9
9No—

Output:

1
3
5
7
9
4(a)What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)
Show solution

Given: myList = [1,2,3,4,5,6,7,8,9,10]

Concept: del myList[3:] deletes all elements from index 33 to the end of the list.

Working:

  • Indices 33 to 99 correspond to elements 4,5,6,7,8,9,104, 5, 6, 7, 8, 9, 10.
  • After deletion, only elements at indices 0,1,20, 1, 2 remain: 1,2,31, 2, 3.

Output:

[1, 2, 3]
4(b)What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)
Show solution

Given: myList = [1,2,3,4,5,6,7,8,9,10]

Concept: del myList[:5] deletes all elements from the beginning up to (but not including) index 55.

Working:

  • Indices 00 to 44 correspond to elements 1,2,3,4,51, 2, 3, 4, 5.
  • After deletion, elements at indices 55 to 99 remain: 6,7,8,9,106, 7, 8, 9, 10.

Output:

[6, 7, 8, 9, 10]
4(c)What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:2]
print(myList)
Show solution

Given: myList = [1,2,3,4,5,6,7,8,9,10]

Concept: del myList[:2] deletes elements from the beginning up to (but not including) index 22.

Working:

  • Indices 00 and 11 correspond to elements 11 and 22.
  • After deletion, elements at indices 22 to 99 remain: 3,4,5,6,7,8,9,103, 4, 5, 6, 7, 8, 9, 10.

Output:

[3, 4, 5, 6, 7, 8, 9, 10]
5Differentiate between append() and extend() functions of list.Show solution

Concept: Both append() and extend() are used to add elements to a list, but they work differently.

Featureappend(x)extend(iterable)
PurposeAdds x as a single element at the endAdds each element of the iterable individually at the end
ArgumentAny object (integer, string, list, etc.)Must be an iterable (list, tuple, string, etc.)
Effect on lengthLength increases by 1Length increases by the number of elements in the iterable
Nested listIf a list is passed, it becomes a nested listIf a list is passed, its elements are added individually

Example:

list1 = [1, 2, 3]
list1.append([4, 5])
print(list1)   # Output: [1, 2, 3, [4, 5]]

list2 = [1, 2, 3]
list2.extend([4, 5])
print(list2)   # Output: [1, 2, 3, 4, 5]

Conclusion: append() adds the argument as one element, while extend() unpacks the iterable and adds each element separately.

6Consider a list: list1 = [6,7,8,9]
What is the difference between the following operations on list1:
a. list1 * 2
b. list1 *= 2
c. list1 = list1 * 2
Show solution

Given: list1 = [6, 7, 8, 9]

**a. list1 * 2**

  • Concept: The * operator creates and returns a new list by repeating list1 twice. The original list1 is not modified.
  • Result: A new list [6, 7, 8, 9, 6, 7, 8, 9] is created but since it is not assigned, list1 remains [6, 7, 8, 9].

**b. list1 = 2*

  • Concept: This is an in-place repetition. It modifies list1 directly (same object in memory) by repeating its elements twice.
  • Result: list1 becomes [6, 7, 8, 9, 6, 7, 8, 9]. The same list object is updated.

**c. list1 = list1 * 2**

  • Concept: list1 * 2 creates a new list [6, 7, 8, 9, 6, 7, 8, 9], and then list1 is reassigned to point to this new list object.
  • Result: list1 now refers to a new list [6, 7, 8, 9, 6, 7, 8, 9].

Summary of Differences:

OperationModifies original?Creates new list?list1 after operation
list1 * 2NoYes (discarded)[6,7,8,9]
list1 *= 2Yes (in-place)No[6,7,8,9,6,7,8,9]
list1 = list1 * 2NoYes (reassigned)[6,7,8,9,6,7,8,9]
7The record of a student is stored in: stRecord = ['Raman','A-36',[56,98,99,72,69], 78.8]
Write Python statements to retrieve:
a) Percentage of the student
b) Marks in the fifth subject
c) Maximum marks of the student
d) Roll no. of the student
e) Change the name of the student from 'Raman' to 'Raghav'

Free with a Super Tutor account

Programming Problems

1Write a program to find the number of times an element occurs in the list.

Free with a Super Tutor account

2Write a program to read a list of n integers (positive as well as negative). Create two new lists, one having all positive numbers and the other having all negative numbers from the given list. Print all three lists.

Free with a Super Tutor account

3Write a function that returns the largest element of the list passed as parameter.

Free with a Super Tutor account

4Write a function to return the second largest number from a list of numbers.

Free with a Super Tutor account

5Write a program to read a list of n integers and find their median.
Note: The median value of a list of values is the middle one when they are arranged in order. If there are two middle values then take their average.

Free with a Super Tutor account

6Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements, i.e., all elements occurring multiple times in the list should appear only once.

Free with a Super Tutor account

7Write a program to read a list of elements. Input an element from the user that has to be inserted in the list. Also input the position at which it is to be inserted. Write a user defined function to insert the element at the desired position in the list.

Free with a Super Tutor account

8(a)Write a program to read elements of a list. The program should ask for the position of the element to be deleted from the list. Write a function to delete the element at the desired position in the list.

Free with a Super Tutor account

8(b)The program should ask for the value of the element to be deleted from the list. Write a function to delete the element of this value from the list.

Free with a Super Tutor account

9Read a list of n elements. Pass this list to a function which reverses this list in-place without creating a new list.

Free with a Super Tutor account

11 more solved questions in Lists

They are free with a Super Tutor account, along with practice quizzes and flashcards for this chapter. Free to start, no card needed.

Frequently Asked Questions

What are the important topics in Lists for CBSE Class 11 Computer Science?
Key topics in Lists include Introduction to Lists, List Operations, Traversing a List, List Methods and Built-in Functions. Study these first, then practise questions on each for Class 11 exams.
Are these NCERT Solutions for Lists free?
The first 11 of the 22 solutions on this page are open to read. The other 11 are free with a Super Tutor account — signing up is free and needs no card.
How should I revise Lists for Class 11 exams?
Learn the core ideas first, then work through the 44 practice questions on Lists. Revise definitions regularly and use flashcards for quick recall before the exam.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Lists chapter — start free.

Quizzes, flashcards, an AI doubt solver and a study plan for CBSE Class 11 Computer Science. Free to start, no card needed.