0% found this document useful (0 votes)
146 views30 pages

Chapter 11 - List Manipulation - Solutions of Computer Science With Python by Sumita Arora For Class 11 CBSE & NCERT - KnowledgeBoat

Chapter 11 of 'Solutions of Computer Science with Python' by Sumita Arora covers list manipulation in Python, including creating lists, accessing elements, and various list operations such as addition, deletion, and slicing. It provides multiple-choice, fill-in-the-blank, true/false questions, and short answer questions to reinforce understanding of lists as mutable data types. The chapter emphasizes the utility of lists in programming and their ability to store heterogeneous data efficiently.

Uploaded by

TVIS Juniors
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views30 pages

Chapter 11 - List Manipulation - Solutions of Computer Science With Python by Sumita Arora For Class 11 CBSE & NCERT - KnowledgeBoat

Chapter 11 of 'Solutions of Computer Science with Python' by Sumita Arora covers list manipulation in Python, including creating lists, accessing elements, and various list operations such as addition, deletion, and slicing. It provides multiple-choice, fill-in-the-blank, true/false questions, and short answer questions to reinforce understanding of lists as mutable data types. The chapter emphasizes the utility of lists in programming and their ability to store heterogeneous data efficiently.

Uploaded by

TVIS Juniors
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class

ora for Class 11 CBSE & NCERT | Kno…

STUDY MATERIAL LOGIN JOIN NOW

Home / Class 11 - Computer Science with Python Sumita Arora / List Manipulation

Chapter 11
List Manipulation
Class 11 - Computer Science with Python Sumita Arora

Meet EZ-PD™ PMG1

Infineon Downloa

Multiple Choice Questions

Question 1

List can contain values of these types:

1. integers
2. floats
3. lists
4. tuples
5. all of these ✓

Question 2

Which of the following will create an empty list?

1. L = [ ] ✓
2. L = list(0)
3. L = list( ) ✓
4. L = List(empty)

Question 3

Which of the following will return the last element of a list L with 5
elements?

1. L[5]
2. L[4] ✓
3. L[-1] ✓
4. L[6]

Question 4

If L = [1, 2] then L * 2 will yield

1. [1, 2] * 2
2. [1, 2, 2]
[Link] 1/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

3. [1, 1, 2, 2]
4. [1, 2, 1, 2] ✓

Question 5

If L1 = [1, 3, 5] and L2 = [2, 4, 6] then L1 + L2 will yield

1. [1, 2, 3, 4, 5, 6]
2. [1, 3, 5, 2, 4, 6] ✓
3. [3, 7, 11]
4. [1, 3, 5, [2, 4, 6]]

Question 6

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[1 : 4]
return?

1. [10, 20, 30, 40]


2. [20, 30, 40, 50]
3. [20, 30, 40] ✓
4. [30, 40, 50]

Question 7

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[2 : -2]
return?

1. [10, 20, 30, 40]


2. [20, 30, 40, 50]
3. [20, 30, 40]
4. [30, 40, 50] ✓

Question 8

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[-4 : -1]
return?

1. [20, 30, 40]


2. [30, 40, 50]
3. [40, 50, 60] ✓
4. [50, 60, 70]

Question 9

Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[-3 : 99]
return?

1. [20, 30, 40]


2. [30, 40, 50]
3. [40, 50, 60]
4. [50, 60, 70] ✓

Question 10

[Link] 2/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

To find the last element of list namely 'smiles' in Python, .......... will
be used.

1. smiles[0]
2. smiles[-1] ✓
3. smiles[lpos]
4. smiles[:-1]

Question 11

Out of the following, what is correct syntax to copy one list into
another?

1. listA = listB[ ]
2. listA = listB[:] ✓
3. listA = listB[ ]( )
4. listA = list(listB) ✓

Question 12

What is printed by the Python code?


print(list(range(3)))

1. [0, 1, 2, 3]
2. [1, 2, 3]
3. [0, 1, 2] ✓
4. 0, 1, 2

Question 13

Which of the following commands will create a list?

1. listl = list( )
2. listl = [ ]
3. listl = list([1, 2, 3])
4. all of these ✓

Question 14

What is the output when we execute list("hello")?

1. ['h', 'e', 'l', 'l', 'o'] ✓


2. ['hello']
3. ['llo']
4. ['olleh']

Question 15

What gets printed?

names = ['Hasan', 'Balwant', 'Sean', 'Dia']


print(names[-1][-1])

1. H

[Link] 3/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

2. n
3. Hasan
4. Dia
5. a ✓

Question 16

What is the output of the following

l = [None] * 10
print(len(l))

1. 10 ✓
2. 0
3. Syntax Error
4. None

Question 17

Consider the list aList - ["SIPO", [1, 3, 5, 7] ]. What would the


following code print?

print(aList[0][1], aList[1][1])

1. S, 3
2. S, 1
3. I, 3 ✓
4. I, 1

Question 18

Which of the following is a standard Python library function and not


an exclusively list function?

1. append( )
2. remove( )
3. pop( )
4. len( ) ✓

Question 19

Which of the following can add only one value to a list?

1. add( )
2. append( ) ✓
3. extend( )
4. none of these

Question 20

Which of the following can add a list of elements to a list?

1. add( )
2. append( )
[Link] 4/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

3. extend( ) ✓
4. none of these

Question 21

Which of the following will always return a list?

1. max( )
2. min( )
3. sort( )
4. sorted( ) ✓

Question 22

Which of the following can delete an element from a list if the index
of the element is given?

1. pop( )
2. remove( )
3. del ✓
4. all of these

Question 23

Which of the following can delete an element from a list, if its value
is given?

1. pop( )
2. remove( ) ✓
3. del
4. all of these

Question 24

Which of the following searches for an element in a list and returns


its index?

1. search( )
2. find( )
3. index( ) ✓
4. lsearch( )

Question 25

Which of the following can copy a list to another list?

1. list( ) ✓
2. new( )
3. copy( ) ✓
4. = operator
Fill in the Blanks

Question 1

[Link] 5/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

Lists are mutable data types and thus their values can be
changed.

Question 2

To create an empty list, function list() can used.

Question 3

The + operator adds one list to the end another list.

Question 4

The * operator replicates a list.

Question 5

To check if an element is in list, in operator is used.

Question 6

To delete a list slice from a list, del statement is used

Question 7

A nested list contains another list as its member.

Question 8

The insert() function is used to insert element at a designated


position in a list.

Question 9

The pop() function is used to delete element to remove an element


from designated index in a list.

Question 10

The extend() function can append a list elements to a list.

Question 11

The sort() function sorts a list and makes changes in the list.

Question 12

The sorted() function sorts a list and returns another list.


True/False Questions

Question 1

The list( ) and copy( ) are the similar functions.


False

Question 2

The pop( ) and remove( ) are similar functions.


False

Question 3

[Link] 6/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

A = [ ] and A = list( ) will produce the same result.


True

Question 4

Lists once created cannot be changed.


False

Question 5

To sort a list, sort( ) and sorted( ), both can be used.


True

Question 6

The extend( ) adds a single element to a list.


False

Question 7

The append( ) can add an element in the middle of a list.


False

Question 8

The insert( ) can add an element in the middle of a list.


True

Question 9

The del statement can only delete list slices and not single
elements from a list.
False

Question 10

The del statement can work similar to the pop( ) function.


True
Type A : Short Answer Questions/Conceptual
Questions

Question 1

Discuss the utility and significance of Lists in Python, briefly.

Answer

Python lists are containers that can store an ordered list of values
of same or different data types together in a single variable. The
fact that elements of a list need not be homogeneous makes them
highly adaptable and powerful data structure in Python. Lists
provide fast access to its elements using index numbers. Python
lists are mutable which makes them memory efficient. They serve
as the basic building blocks for programs that process large
amounts of data.

Question 2

[Link] 7/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

What do you understand by mutability? What does "in place"


memory updation mean?

Answer

Mutability means that the value of an object can be updated by


directly changing the contents of the memory location where the
object is stored. There is no need to create another copy of the
object in a new memory location with the updated values. This
updation of the existing memory location of the object is called as
in place memory updation.

Question 3

Start with the list [8, 9, 10]. Do the following using list functions:

1. Set the second entry (index 1) to 17


2. Add 4, 5 and 6 to the end of the list
3. Remove the first entry from the list
4. Sort the list
5. Double the list
6. Insert 25 at index 3

Answer

listA = [8, 9, 10]

1. listA[1] = 17
2. [Link]([4, 5, 6])
3. [Link](0)
4. [Link]()
5. listA = listA * 2
6. [Link](3, 25)

Question 4

If a is [1, 2, 3]

1. what is the difference (if any) between a * 3 and [a, a, a]?


2. is a * 3 equivalent to a + a + a?
3. what is the meaning of a[1:1] = 9?
4. what's the difference between a[1:2] = 4 and a[1:1] = 4?

Answer

1. a * 3 ⇒ [1, 2, 3, 1, 2, 3, 1, 2, 3]
[a, a, a] ⇒ [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
So, a * 3 repeats the elements of the list whereas [a, a, a]
creates nested list.
2. Yes, both a * 3 and a + a + a will result in [1, 2, 3, 1, 2, 3, 1, 2,
3]
3. a[1:1] = 9 will cause an error because when list is modified
using slices, the value being assigned must be a sequence

[Link] 8/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

but 9 is an integer not a sequence.


4. Both a[1:2] = 4 and a[1:1] = 4 will cause error because when
list is modified using slices, the value being assigned must be
a sequence but 4 is an integer not a sequence. Assuming the
question was a[1:2] = [4] and a[1:1] = [4], a[1:2] = [4] will
change element at index 1 to 4 as a[1:2] gives a slice with a[1]
as its only element. Thus, a becomes [1, 4, 3]. Coming to
a[1:1] = [4], a[1:1] returns an empty slice so 4 is inserted into
the list at index 1. Thus, a becomes [1, 4, 2, 3].

Question 5

What's a[1 : 1] if a is a list of at least two elements? And what if the


list is shorter?

Answer

a[x:y] returns a slice of the sequence from index x to y - 1. So, a[1 :


1] will return an empty list irrespective of whether the list has two
elements or less as a slice from index 1 to index 0 is an invalid
range.

Question 6

How are the statements lst = lst + 3 and lst += [3] different, where
lst is a list? Explain.

Answer

The statement lst = lst + 3 will give error as + operator in Python


requires that both its operands should be of the same type but
here one operand is list and other is integer. The statement lst +=
[3] will add 3 at the end of the lst as += when used with lists
requires the operand on the right side to be an iterable and it will
add each element of the iterable to the end of the list.

Question 7

How are the statements lst += "xy" and lst = lst + "xy" different,
where lst is a list? Explain.

Answer

The statement lst = lst + "xy" will give error as + operator in Python
requires that both its operands should be of the same type but
here one operand is list and other is string. The statement lst +=
"xy" will add 'x' and 'y' at the end of the lst as += when used with
lists requires the operand on the right side to be an iterable and it
will add each element of the iterable to the end of the list.

Question 8

What's the purpose of the del operator and pop method? Try
deleting a slice.

Answer

[Link] 9/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

The del statement is used to remove an individual element or


elements identified by a slice. It can also be used to delete all
elements of the list along with the list object. For example,

lst = [1, 2, 3, 4, 5, 6, 7, 8]
del lst[1] # delete element at index 1
del lst[2:5] # delete elements from index 2 to 4
del lst # delete complete list

pop() method is used to remove a single element from the given


position in the list and return it. If no index is specified, pop()
removes and returns the last element in the list. For example,

lst = [1, 2, 3, 4, 5, 6, 7, 8]

# removes element at
# index 1 i.e. 2 from
# the list and stores
# in variable a
a = pop(1)

# removes the last element


# i.e. 8 from the list and
# stores in variable b
b = pop()

Question 9

What does each of the following expressions evaluate to?


Suppose that L is the list
["These", ["are", "a", "few", "words"], "that", "we", "will", "use"].

1. L[1][0::2]
2. "a" in L[1][0]
3. L[:1] + L[1]
4. L[2::2]
5. L[2][2] in L[1]

Answer

1. ['are', 'few']
2. True
3. ['These', 'are', 'a', 'few', 'words']
4. ['that', 'will']
5. True

Explanation

1. L[1] returns ["are", "a", "few", "words"]. L[1][0::2] returns a slice


of ["are", "a", "few", "words"] starting at index 0 covering every
alternate element till the end of the list. So, final output is
['are', 'few'].
2. L[1][0] is "are". As "a" is present in "are" so output is True.

[Link] 10/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

3. L[:1] return L[0] i.e. ["These"]. L[1] returns ["are", "a", "few",
"words"]. + operator adds the two in a single list to give the
final output as ['These', 'are', 'a', 'few', 'words'].
4. L[2::2] returns a slice of L starting at index 2 covering every
alternate element till the end of the list. So, final output is
['that', 'will'].
5. L[1] is ["are", "a", "few", "words"]. L[2][2] is "a". As "a" is
present in L[1] so output is True.

Question 10

What are list slices? What for can you use them?

Answer

List slice is an extracted part of the list containing the requested


elements. The list slice is a list in itself. All list operations can be
performed on a list slice. List slices are used to copy the required
elements to a new list and to modify the required parts of the list.
For example,

lst = [1, 2, 3, 4, 5]
lst2 = lst[1:4] #lst2 is [2, 3, 4]

#Using Slices for list modification


lst[0:2] = [10, 20] #lst becomes [10, 20, 3, 4, 5]

Question 11

Does the slice operator always produce a new list?

Answer

Slice operator copies only the requested elements of the original


list into a new list.

Question 12

Compare lists with strings. How are they similar and how are they
different?

Answer

The similarity between Lists and Strings in Python is that both are
sequences. The differences between them are that firstly, Lists are
mutable but Strings are immutable. Secondly, elements of a list
can be of different types whereas a String only contains characters
that are all of String type.

Question 13

What do you understand by true copy of a list? How is it different


from shallow copy?

Answer

[Link] 11/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

True copy of a list means that the elements of the original list are
copied to new memory locations and the new list contains
references to these new memory locations for each element of the
list. Hence, in case of true copy changes made to the original list
will not reflect in the copied list and vice versa.

Incase of shallow copy of a list, the elements of the original list are
not copied to new memory locations. Both the new list and the
original list refer to the same memory locations for the elements of
the list. Hence, changes made to one of the list reflect in the other
list as well.

Question 14

An index out of bounds given with a list name causes error, but not
with list slices. Why?

Answer

When we use an index, we are accessing a constituent element of


the list. If the index is out of bounds there is no element to return
from the given index hence Python throws list index out of range
error whereas list slicing always returns a subsequence and empty
subsequence is a valid sequence. Thus, when a list is sliced
outside the bounds, it still can return empty subsequence and
hence Python gives no errors and returns empty subsequence.

Question 15

What is the difference between appending a list and extending a


list?

Answer

Appending a list Extending a list

For appending to a list, For extending a list, extend()


append() function is used. function is used.

The append() function The extend() function can add


can add a single element multiple elements from a list
to the end of a list. supplied to it as argument.

After append(), the length After extend() the length of the list
of the list will increase by will increase by the length of the
1 element only. list given as argument to extend()

Question 16

Do functions max( ), min( ), sum( ) work with all types of lists.

Answer

No, for max() and min() to work on a list, the list must contain all
elements of same type (non-complex type) and for sum() to work,

[Link] 12/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

the list must contain the elements which can be added such as
numbers.

Question 17

What is the difference between sort( ) and sorted( )?

Answer

sort( ) sorted( )

It modifies the list it is


It creates a new list containing a
called on. That is, the
sorted version of the list passed to
sorted list is stored in the
it as argument. It does not modify
same list; a new list is
the list passed as a parameter.
not created.

It can take any iterable sequence


type, such as a list or a tuple etc,
It works on a list and
and it always returns a sorted list
modifies it.
irrespective of the type of
sequence passed to it.

It does not return


It returns a newly created sorted
anything (no return
list. It does not change the passed
value). It modifies the list
sequence.
in place.
Type B: Application Based Questions

Question 1

What is the difference between following two expressions, if lst is


given as [1, 3, 5]

(i) lst * 3 and lst *= 3


(ii) lst + 3 and lst += [3]

Answer

(i)

lst * 3 will give [1, 3, 5, 1, 3, 5, 1, 3, 5] but the original lst will


remains unchanged, it will be [1, 3, 5] only.
lst *= 3 will also give [1, 3, 5, 1, 3, 5, 1, 3, 5] only but it will assign
this result back to lst so lst will be changed to [1, 3, 5, 1, 3, 5, 1, 3,
5].

(ii)

lst + 3 will cause an error as both operands of + operator should


be of same type but here one operand is list and the other integer.
lst += [3] will add 3 to the end of lst so lst becomes [1, 3, 5, 3].

Question 2

Given two lists:

[Link] 13/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

L1 = ["this", 'is', 'a', 'List'], L2 = ["this", ["is", "another"], "List"]

Which of the following expressions will cause an error and why?

1. L1 == L2
2. [Link]( )
3. L1[3].upper( )
4. [Link]( )
5. L2[1].upper( )
6. L2[1][1].upper( )

Answer

[Link]( ) will cause an error as upper() method can be


called with Strings not Lists.
[Link]( ) will cause an error as upper() method can be
called with Strings not Lists.
L2[1].upper( ) will cause an error as L2[1] is a list — [ "is",
"another"] and upper() method cannot be called on Lists.

Question 3

From the previous question, give output of expressions that do not


result in error.

Answer

L1 == L2 gives output as false because L1 is not equal to L2.


L1[3].upper( ) gives output as 'LIST' because L1[3] is 'List' and
upper() function converts it to uppercase.
L2[1][1].upper( ) gives output as 'ANOTHER' because L2[1]
["is", "another"] and L2[1][1] is "another". upper() function
converts it to uppercase.

Question 4

Given a list L1 = [3, 4.5, 12, 25.7, [2, 1, 0, 5], 88]

1. Which list slice will return [12, 25.7, [2, 1, 0, 5]]?


2. Which expression will return [2, 1, 0, 5]?
3. Which list slice will return [[2, 1, 0, 5]]?
4. Which list slice will return [4.5, 25.7, 88]?

Answer

1. L1[2:5]
2. L1[4]
3. L1[4:5]
4. L1[1::2]

Question 5

Given a list L1 = [3, 4.5, 12, 25.7, [2, 1, 0, 5], 88], which function
can change the list to:

[Link] 14/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

1. [3, 4.5, 12, 25.7, 88]


2. [3, 4.5, 12, 25.7]
3. [ [2, 1, 0, 5], 88]

Answer

1. [Link](4)
2. del L1[4:6]
3. del L1[:4]

Question 6

What will the following code result in?

L1 = [1, 3, 5, 7, 9]
print (L1 == [Link]( ) )
print (L1)

Answer

Output

False
[9, 7, 5, 3, 1]

Explanation

L1 is not equal to its reverse so L1 == [Link]( ) gives False but


[Link]( ) reverses L1 in place so after that statement
executes, L1 becomes [9, 7, 5, 3, 1].

Question 7

Predict the output:

my_list= [ 'p', 'r', 'o', 'b', 'l' , 'e', 'm']


my_list[2:3] = []
print(my_list)
my_list[2:5] = []
print(my_list)

Answer

Output

['p', 'r', 'b', 'l', 'e', 'm']


['p', 'r', 'm']

Explanation

my_list[2:3] = [] removes element at index 2 of my_list so it


becomes ['p', 'r', 'b', 'l', 'e', 'm']. my_list[2:5] removes elements at
indexes 2, 3, and 4 so now my_list becomes ['p', 'r', 'm'].

Question 8

Predict the output:

[Link] 15/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

List1 = [13, 18, 11, 16, 13, 18, 13]


print([Link](18))
print([Link](18))
[Link]([Link](13))
print(List1)

Answer

Output

1
2
[13, 18, 11, 16, 13, 18, 13, 3]

Explanation

[Link](18) gives the first index of element 18 in List1 which in


this case is 1. [Link](18) returns how many times 18 appears
in List1 which in this case is 2. [Link](13) returns 3 as 13
appears 3 times in List1. [Link]([Link](13)) add this 3
to the end of List1 so it becomes [13, 18, 11, 16, 13, 18, 13, 3].

Question 9

Predict the output:

Odd = [1,3,5]
print( (Odd +[2, 4, 6])[4] )
print( (Odd +[12, 14, 16])[4] - (Odd +[2, 4, 6])[4] )

Answer

Output

4
10

Explanation

Odd + [2, 4, 6] will return [1, 3, 5, 2, 4, 6]. The element at index 4


of this list is 4 so the first output is 4. (Odd +[12, 14, 16])[4] is 14
and (Odd +[2, 4, 6])[4] is 4. 14 - 4 = 10 which is the second output.

Question 10

Predict the output:

a, b, c = [1,2], [1, 2], [1, 2]


print(a == b)
print (a is b)

Answer

Output

True
False

[Link] 16/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…
Explanation

As corresponding elements of list a and b are equal hence a == b


returns True. a is b returns False as a and b are two different list
objects referencing two different memory locations.

Question 11

Predict the output of following two parts. Are the outputs same?
Are the outputs different? Why?

(a)

L1, L2 = [2, 4] , [2, 4]


L3 = L2
L2[1] = 5
print(L3)

(b)

L1, L2 = [2, 4] , [2, 4]


L3 = list(L2)
L2[1] = 5
print(L3)

Answer

Output of part (a) is:


[2, 5]

Output of part (b) is:


[2, 4]

As we can see, outputs of the two parts are different. The reason is
that in part (a), the statement L3 = L2 creates a shallow copy of L2
in L3 i.e. both the variables L2 and L3 point to the same list.
Hence, when element at index 1 of L2 is changed to 5, that change
is visible in L3 also. On the other hand in part (b), the statement L3
= list(L2) creates a true copy (also called deep copy) of L2 so L3
points to a different list in memory which has the same elements
as L2. Now when element at index 1 of L2 is changed to 5, that
change is not visible in L3.

Question 12

Find the errors:

1. L1 = [1, 11, 21, 31]


2. L2 = L1 + 2
3. L3 = L1 * 2
4. Idx = [Link](45)

Answer

Line 2 — L2 = L1 + 2 will result in error as one element of + is


a list and other is an integer. In Python, operands of +
operator should be of same type.

[Link] 17/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

Line 4 — Idx = [Link](45) will cause an error as 45 is not


present in the list L1.

Question 13a

Find the errors:

L1 = [1, 11, 21, 31]


An = [Link](41)

Answer

[Link](41) will cause an error as 41 is not present in L1.

Question 13b

Find the errors:

L1 = [1, 11, 21, 31]


An = [Link](31)
print(An + 2)

Answer

An + 2 will cause an error because remove() function does not


return the removed element so An will be None. Addition operator
(+) does not allow any of its operands to be None hence, it will
raise a TypeError.

Question 14a

Find the errors:

L1 = [3, 4, 5]
L2 = L1 * 3
print(L1 * 3.0)
print(L2)

Answer

The line print(L1 * 3.0) causes an error as Python does not allow
multiplying a list with a non-int number and 3.0 is of float type.

Question 14b

Find the errors:

L1 = [3, 3, 8, 1, 3, 0, '1', '0', '2', 'e', 'w', 'e', 'r']


print(L1[: :-1])
print(L1[-1:-2:-3])
print(L1[-1:-2:-3:-4])

Answer

The line print(L1[-1:-2:-3:-4]) causes an error as its syntax is


invalid. The correct syntax for slicing a list is L1[start:stop:step].

Question 15

[Link] 18/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

What will be the output of following code?

x = ['3', '2', '5']


y = ''
while x:
y = y + x[-1]
x = x[:len(x) - 1]
print(y)
print(x)
print(type(x), type(y))

Answer

Output

523
[]
<class 'list'> <class 'str'>

Explanation

The loop while x will continue executing as long as the length of list
x is greater than 0. y is initially an empty string. Inside the loop, we
are adding the last element of x to y and after that we are
removing the last element of x from x. So, at the end of the loop y
becomes 523 and x becomes empty. Type of x and y are list and
str respectively.

Question 16

Complete the code to create a list of every integer between 0 and


100, inclusive, named nums1 using Python, sorted in increasing
order.

Answer

nums1 = list(range(101))

Question 17

Let nums2 and nums3 be two non-empty lists. Write a Python


command that will append the last element of nums3 to the end of
nums2.

Answer

[Link](nums3[-1])

Question 18

Consider the following code and predict the result of the following
statements.

bieber = ['om', 'nom', 'nom']


counts = [1, 2, 3]
nums = counts
[Link](4)

1. counts is nums

[Link] 19/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

2. counts is add([1, 2], [3, 4])

Answer

1. Output is True as both nums and counts refer to the same list.
2. This will cause an error as add function is not defined in the
above code.

Question 19

What is the output of the following code?

numbers = list(range(0, 51, 4))


results = []
for number in numbers:
if not number % 3:
[Link](number)
print(results)

Answer

Output

[0, 12, 24, 36, 48]

Explanation

list(range(0, 51, 4)) will create a list from 0 to 48 with a step of 4 so


numbers will be [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]. For
loop will traverse the list one number at a time. if not number % 3
means if number % 3 is equal to 0 i.e. number is divisible by 3. The
numbers divisible by 3 are added to the results list and after the
loop results list is printed.

Question 20

Following code prints the given list in ascending order. Modify the
code so that the elements are printed in the reverse order of the
result produced by the given code.

numbers = list(range(0, 51, 4))


i = 0
while i < len(numbers):
print(numbers[i] , end = " ")
i += 3
# gives output as : 0 12 24 36 48

Answer

numbers = list(range(0, 51, 4))


i = len(numbers) - 1
while i >= 0:
print(numbers[i] , end = " ")
i -= 3

Output

[Link] 20/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

48 36 24 12 0

Type C: Programming Practice/Knowledge based


Questions

Question 1

Write a program to increment the elements of a list with a number.

Solution

lst = eval(input("Enter a list: "))


print("Existing list is:", lst)

n = int(input("Enter a number: "))

for i in range(len(lst)):
lst[i] += n

print("List after increment:", lst)

Output

Enter a list: [1, 2, 3, 4, 5]


Existing list is: [1, 2, 3, 4, 5]
Enter a number: 10
List after increment: [11, 12, 13, 14, 15]

Question 2

Write a program that reverses a list of integers (in place).

Solution

l = eval(input("Enter a list: "))


print("Original list:", l)
[Link]()
print("Reversed list:", l)

Output

Enter a list: [1, 2, 3, 4, 5]


Original list: [1, 2, 3, 4, 5]
Reversed list: [5, 4, 3, 2, 1]

Question 3

Write a program that inputs two lists and creates a third, that
contains all elements of the first followed by all elements of the
second.

Solution

l1 = eval(input("Enter first list: "))


l2 = eval(input("Enter second list: "))
l3 = l1 + l2
print("Joined List:", l3)

Output

[Link] 21/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

Enter first list: [1, 2, 3, 4, 5]


Enter second list: [11, 12, 13, 14, 15]
Joined List: [1, 2, 3, 4, 5, 11, 12, 13, 14, 15]

Question 4

Ask the user to enter a list containing numbers between 1 and 12.
Then replace all of the entries in the list that are greater than 10
with 10.

Solution

l = eval(input("Enter list having numbers between 1 & 12: "))

for i in range(len(l)):
if l[i] > 10:
l[i] = 10

print("List after removing numbers greater than 10:")


print(l)

Output

Enter list having numbers between 1 & 12: [1, 3, 15, 8, 20]
List after removing numbers greater than 10:
[1, 3, 10, 8, 10]

Question 5

Ask the user to enter a list of strings. Create a new list that
consists of those strings with their first characters removed.

Solution

l1 = eval(input("Enter a list of strings: "))


l2 = []

for i in range(len(l1)):
[Link](l1[i][1:])

print("List after removing first characters:")


print(l2)

Output

Enter a list of strings: ["red", "green", "blue", "pink", "cya


List after removing first characters:
['ed', 'reen', 'lue', 'ink', 'yan']

Question 6

Write a program to check if a number is present in the list or not. If


the number is present, print the position of the number. Print an
appropriate message if the number is not present in the list.

Solution

[Link] 22/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

l = eval(input("Enter list: "))


n = int(input("Enter number to search: "))

if n in l:
print(n, "found at index", [Link](n))
else :
print(n, "not found in list")

Output

Enter list: [1, 3, 15, 8, 20]


Enter number to search: 15
15 found at index 2

=====================================

Enter list: [1, 3, 15, 8, 20]


Enter number to search: 25
25 not found in list

Question 7a

Create the following lists using a for loop:

A list consisting of the integers 0 through 49.

Solution

l = []

for i in range(50):
[Link](i)

print("List with integers from 0 to 49:")


print(l)

Output

List with integers from 0 to 49:


[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,

Question 7b

Create the following lists using a for loop:

A list containing the squares of the integers 1 through 50.

Solution

l = []

for i in range(1, 51):


[Link](i * i)

print("List with square of integers from 1 to 50:")


print(l)

Output

[Link] 23/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

List with square of integers from 1 to 50:


[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225

Question 7c

Create the following lists using a for loop:

The list ['a','bb','ccc','dddd', . . . ] that ends with 26 copies of the


letter z.

Solution

l = []

for i in range(1, 27):


[Link](chr(i + 96) * i)

print("Created List:")
print(l)

Output

Created List:
['a', 'bb', 'ccc', 'dddd', 'eeeee', 'ffffff', 'ggggggg', 'hhhh
'vvvvvvvvvvvvvvvvvvvvvv', 'wwwwwwwwwwwwwwwwwwwwwww', 'xxxxxxxx

Question 8

Write a program that takes any two lists L and M of the same size
and adds their elements together to form a new list N whose
elements are sums of the corresponding elements in L and M. For
instance, if L = [3, 1, 4] and M = [1, 5, 9], then N should equal
[4,6,13].

Solution

print("Enter two lists of same size")


L = eval(input("Enter first list(L): "))
M = eval(input("Enter second list(M): "))
N = []

for i in range(len(L)):
[Link](L[i] + M[i])

print("List N:")
print(N)

Output

Enter two lists of same size


Enter first list(L): [3, 1, 4]
Enter second list(M): [1, 5, 9]
List N:
[4, 6, 13]

Question 9

[Link] 24/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…

Write a program rotates the elements of a list so that the element


at the first index moves to the second index, the element in the
second index moves to the third index, etc., and the element in the
last index moves to the first index.

Solution

l = eval(input("Enter the list: "))


print("Original List")
print(l)

l = l[-1:] + l[:-1]

print("Rotated List")
print(l)

Output

Enter the list: [8, 10, 13, 25, 7, 11]


Original List
[8, 10, 13, 25, 7, 11]
Rotated List
[11, 8, 10, 13, 25, 7]

Question 10

Write a program that reads the n to display nth term of Fibonacci


series.

The Fibonacci sequence works as follows:

element 0 has the value 0


element 1 has the value 1
every element after that has the value of the sum of the two
preceding elements

The beginning of the sequence looks like:


0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

The program prompts for element and prints out the value of that
element of the Fibonacci sequence.

Thus:

input 7, produces 13
input 9, produces 34

Hints:
A Don't try to just type out the entire list. It gets big very fast.
Element 25 is 75205. Element 100 is 354224848179261915075.
So keep upper limit of n to 20.

Solution

n = int(input("Enter n: "))

if (n > 20):
print("n should be less than or equal to 20")

[Link] 25/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…
else :
a = 0
b = 1
c = a + b
for i in range(3, n + 1):
a = b
b = c
c = a + b

print(n, "term of Fibonacci series =", c)

Output

Enter n: 7
7 term of Fibonacci series = 13

Search by lesson title =====================================

Chapter 1
Computer System Overview
Enter n: 9
9 term of Fibonacci series = 34
Chapter 2
Data Representation
=====================================
Chapter 6
Getting Started with Python
Enter n: 25
Chapter 7 n should be less than or equal to 20
Python Fundamentals CONTENTS

Chapter 8 Multiple Choice Questions


Data Handling
Question 11a
Fill in the Blanks
True/False Questions
Chapter 9 Write programs as per following specifications:
Flow of Control Type A : Short Answer
Questions/Conceptual
Questions
Chapter 10 '''Print the length of the longest Type B: Application Based
String Manipulation Questions
string in the list of strings str_list. Type C: Programming
Chapter 11 Practice/Knowledge based
List Manipulation
Precondition : the list will contain Questions

Chapter 12
at least one element.'''
Tuples

Solution
Chapter 13
Dictionaries

l = eval(input("Enter list of strings: "))


largeIdx = 0
largeLen = 0

for i in range(len(l)):
length = len(l[i])
if length > largeLen:
largeLen = length
largeIdx = i

print("Longest String:", l[largeIdx])

Output

Enter list of strings: ["apple", "orange", "pear", "strawberry


Longest String: strawberry

Question 11b

Write programs as per following specifications:

'''L is a list of numbers. Print a new list where each element is the
corresponding element of list L summed with number num.'''

[Link] 26/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…
Solution

l1 = eval(input("Enter list of numbers: "))


num = int(input("Enter the number to sum with (num): "))

l2 = []

for i in l1:
[Link](i + num)

print("New list:")
print(l2)

Output

Enter list of numbers: [10, 20, 30, 40, 50]


Enter the number to sum with (num): 15
New list:
[25, 35, 45, 55, 65]

Question 12

Write a program to read two lists num and denum which contain
the numerators and denominators of same fractions at the
respective indexes. Then display the smallest fraction along with
its index.

Solution

num = eval(input("Enter numerators list: "))


denum = eval(input("Enter denominators list: "))

small = 0.0
smallIdx = 0

for i in range(len(num)):
t = num[i] / denum[i]
if t < small:
small = t
smallIdx = i

print("Smallest Fraction =", num[smallIdx], "/", denum[smallId


print("Index of Smallest Fraction =", smallIdx)

Output

Enter numerators list: [1, 3, 1, 7, 3]


Enter denominators list: [2, 4, 4, 13, 8]
Smallest Fraction = 1 / 2
Index of Smallest Fraction = 0

Question 13

Write a program to display the maximum and minimum values from


the specified range of indexes of list.

Solution

l = eval(input("Enter the list: "))


start = int(input("Enter start index: "))

[Link] 27/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…
stop = int(input("Enter stop index: "))

slice = l[start : stop + 1]


mx = max(slice)
mi = min(slice)

print("Maximum =", mx)


print("Minimum =", mi)

Output

Enter the list: [89, 42, 12, 56, 35, 2, 8, 7, 13, 69]
Enter start index: 3
Enter stop index: 8
Maximum = 56
Minimum = 2

Question 14

Write a program to move all duplicate values in a list to the end of


the list.

Solution

l = eval(input("Enter the list: "))


dedup = []
dup = []
for i in l:
if i in dedup:
[Link](i)
else:
[Link](i)

l = dedup + dup

print("Modified List:")
print(l)

Output

Enter the list: [20, 15, 18, 15, 7, 18, 12, 13, 7]
Modified List:
[20, 15, 18, 7, 12, 13, 15, 18, 7]

Question 15

Write a program to compare two equal sized lists and print the first
index where they differ.

Solution

print("Enter two equal sized lists")


l1 = eval(input("Enter first list: "))
l2 = eval(input("Enter second list: "))

for i in range(len(l1)):
if l1[i] != l2[i]:
print("Lists differ at index", i)
break;
else:
print("Lists are equal")

[Link] 28/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…
Output

Enter two equal sized lists


Enter first list: [80, 60, 50, 40, 30]
Enter second list: [80, 60, 55, 42, 30]
Lists differ at index 2

=====================================

Enter two equal sized lists


Enter first list: [80, 60, 50, 40, 30]
Enter second list: [80, 60, 50, 40, 30]
Lists are equal

Prev Next
String Manipulation Tuples

ICSE/ISC TEXTBOOK SOLUTIONS ICSE/ISC/CBSE PRACTICE TESTS COMPANY

Class - 6 Concise Biology Selina Solutions Class - 9 ICSE Mathematics Sample Paper Tests Pricing

Class - 6 Veena Bhargava Geography Solutions Class - 9 ICSE Biology Practice Tests About Us

Class - 6 Effective History & Civics Solutions Class - 10 ICSE Mathematics Sample Paper Tests Contact Us

Class - 7 Concise Physics Selina Solutions Class - 10 ICSE Biology Sample Paper Tests Privacy Policy

Class - 7 Concise Chemistry Selina Solutions Class - 12 CBSE Computer Science Sample Paper Tests Terms of Service

Class - 7 Dalal Simplified Middle School Chemistry Solutions Class - 12 CBSE Informatics Practices Sample Paper Tests

Class - 7 Concise Biology Selina Solutions STUDYLIST

Class - 7 Living Science Biology Ratna Sagar Solutions Java Pattern Programs

Class - 7 Around the World Geography Solutions Java Series Programs

Class - 7 Veena Bhargava Geography Solutions Java Number Programs (ICSE Classes 9 / 10)

Class - 7 Effective History & Civics Solutions Java Number Programs (ISC Classes 11 / 12)

Class - 8 Concise Physics Selina Solutions Output Questions for Class 10 ICSE Computer Applications

Class - 8 Concise Chemistry Selina Solutions Algorithms & Flowcharts for ICSE Computers

Class - 8 Dalal Simplified Middle School Chemistry Solutions ICSE Class 8 Computers Differentiate Between the Following

Class - 8 Concise Biology Selina Solutions CBSE TEXTBOOK SOLUTIONS

Class - 8 Living Science Biology Ratna Sagar Solutions Class - 8 NCERT Science Solutions

Class - 8 Around the World Geography Solutions Class - 9 NCERT Mathematics Solutions

Class - 8 Veena Bhargava Geography Solutions Class - 9 NCERT Science Solutions

Class - 8 Effective History & Civics Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions

Class - 8 Kips Logix Computers Solutions Class - 9 NCERT History India & Contemporary World 1 Solutions

Class - 9 Concise Physics Selina Solutions Class - 9 Sumita Arora Computer Code 165 Solutions

Class - 9 Concise Chemistry Selina Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions

Class - 9 Dalal Simplified ICSE Chemistry Solutions Class - 10 NCERT Mathematics Solutions

Class - 9 Concise Biology Selina Solutions Class - 10 NCERT Science Solutions

Class - 9 Total Geography Morning Star Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions

Class - 9 Veena Bhargava Geography Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions

Class - 9 Total History & Civics Solutions Class - 10 NCERT Democratic Politics 2 (Civics) Solutions

Class - 9 Kips Logix Computers Solutions Class - 10 NCERT Economic Development Solutions

Class - 10 Concise Physics Selina Solutions Class - 10 Sumita Arora Computer Code 165 Solutions

[Link] 29/30
2/4/25, 3:44 PM Chapter 11: List Manipulation | Solutions of Computer Science with Python by Sumita Arora for Class 11 CBSE & NCERT | Kno…
Class - 10 Concise Chemistry Selina Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions

Class - 10 Dalal Simplified ICSE Chemistry Solutions Class - 11 CBSE Sumita Arora Python Solutions

Class - 10 Concise Biology Selina Solutions Class - 11 CBSE Preeti Arora Python Solutions

Class - 10 Total Geography Morning Star Solutions Class - 11 CBSE Informatics Practices Preeti Arora Solutions

Class - 10 Veena Bhargava Geography Solutions Class - 12 CBSE Sumita Arora Python Solutions

Class - 10 Total History & Civics Solutions Class - 12 CBSE Preeti Arora Python Solutions

Class - 10 Sumita Arora ICSE Computers Solutions Class - 12 NCERT Computer Science Solutions

Class - 10 Kips Logix Computers Solutions Class - 12 CBSE Informatics Practices Sumita Arora Solutions
ICSE/ISC SOLVED QUESTION PAPERS
Class - 12 CBSE Informatics Practices Preeti Arora Solutions
Class - 10 ICSE Maths Solved Competency Focused Questions

Class - 10 ICSE Biology Solved Competency Focused Questions

ICSE Class 10 Computers Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Computer Applications

ICSE Class 10 Physics Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Physics

ICSE Class 10 Chemistry Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Chemistry

ICSE Class 10 Biology Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Biology

ICSE Class 10 Maths Solved Previous Yrs Question Papers

Class - 12 ISC Computer Science Solved Practical Papers

Class - 10 CBSE Computer Applications Solved Question Papers

Class - 10 CBSE Computer Applications Solved Sample Papers

Class - 10 CBSE Science Solved Question Papers

Class - 12 CBSE Computer Science Solved Question Papers

Class - 12 CBSE Informatics Practices Solved Question Papers

Copyright © KnowledgeBoat 2025

[Link] 30/30

You might also like