1st pu notes

1st PUC Computer Science Chapter 9 Lists Notes | Class 11 Python Lists

Venkatesh A August 19, 2026 24 min read

VerakWorld

Complete Short Notes & Exam Preparation Guide
Based on the NCERT Class XI Computer Science textbook PDF

πŸ“š Chapter Overview VerakWorld

A list is an ordered sequence that is mutable and can contain one or more elements. Unlike a string, which contains only characters, a list can contain elements of different data types such as integers, floats, strings, tuples and even another list.

List elements are enclosed in square brackets [ ] and separated by commas. List indexing starts from 0.

Exam Point: Lists are ordered, mutable sequences and their indices start from 0.

πŸ“‘ Table of Contents VerakWorld

9.1 Introduction to List VerakWorld

The data type list is an ordered sequence which is mutable and made up of one or more elements.

A list can contain elements belonging to different data types such as integer, float, string, tuple or even another list.

Elements of a list are enclosed in square brackets and separated by commas. Like string indices, list indices also start from 0.

Key Points: VerakWorld
  • List is an ordered sequence.
  • List is mutable.
  • A list can contain mixed data types.
  • Elements are enclosed in square brackets.
  • Elements are separated by commas.
  • Indexing starts from 0.
  • A list can contain another list, forming a nested list.
List Indexing VerakWorld
2
Index 0
4
Index 1
6
Index 2
8
Index 3
10
Index 4
12
Index 5
Caption: List elements and their corresponding indices.
Example 9.1 VerakWorld
#list1 is the list of six even numbers
>>> list1 = [2,4,6,8,10,12]
>>> print(list1)
[2, 4, 6, 8, 10, 12]

#list2 is the list of vowels
>>> list2 = ['a','e','i','o','u']
>>> print(list2)
['a', 'e', 'i', 'o', 'u']

#list3 is the list of mixed data types
>>> list3 = [100,23.5,'Hello']
>>> print(list3)
[100, 23.5, 'Hello']

#list4 is the list of lists called nested list
>>> list4 =[['Physics',101],['Chemistry',202], ['Maths',303]]
>>> print(list4)
[['Physics', 101], ['Chemistry', 202], ['Maths', 303]]
VerakWorld

9.1.1 Accessing Elements in a List VerakWorld

The elements of a list are accessed in the same way as characters are accessed in a string.

#initializes a list list1
>>> list1 = [2,4,6,8,10,12]

>>> list1[0]
2

>>> list1[3]
8

#return error as index is out of range
>>> list1[15]
IndexError: list index out of range

#an expression resulting in an integer index
>>> list1[1+4]
12

>>> list1[-1]
12

#length of the list list1 is assigned to n
>>> n = len(list1)
>>> print(n)
6

#return the last element of the list1
>>> list1[n-1]
12

#return the first element of list1
>>> list1[-n]
2
VerakWorld
Exam Point: Positive indexing starts from the left at 0. Negative indexing accesses elements from the right.

9.1.2 Lists are Mutable VerakWorld

In Python, lists are mutable. This means that the contents of a list can be changed after it has been created.

#List list1 of colors
>>> list1 = ['Red','Green','Blue','Orange']

#change/override the fourth element of list1
>>> list1[3] = 'Black'

>>> list1
['Red', 'Green', 'Blue', 'Black']
VerakWorld
Remember: Mutable means the contents can be changed after creation.

9.2 List Operations VerakWorld

The data type list allows manipulation of its contents through various operations.

  • Concatenation
  • Repetition
  • Membership
  • Slicing

9.2.1 Concatenation VerakWorld

Python allows us to join two or more lists using the concatenation operator represented by the symbol +.

list1 + list2
#list1 is list of first five odd integers
>>> list1 = [1,3,5,7,9]

#list2 is list of first five even integers
>>> list2 = [2,4,6,8,10]

#elements of list1 followed by list2
>>> list1 + list2
[1, 3, 5, 7, 9, 2, 4, 6, 8, 10]

>>> list3 = ['Red','Green','Blue']
>>> list4 = ['Cyan', 'Magenta', 'Yellow' ,'Black']

>>> list3 + list4
['Red','Green','Blue','Cyan','Magenta',
 'Yellow','Black']
VerakWorld
There is no change in the original lists after concatenation. To store the merged list, use an assignment statement.

The concatenation operator + requires both operands to be lists. Concatenating a list with another data type produces a TypeError.

>>> list1 = [1,2,3]
>>> str1 = "abc"
>>> list1 + str1
TypeError: can only concatenate list (not "str") to list
VerakWorld

9.2.2 Repetition VerakWorld

Python allows us to replicate a list using the repetition operator represented by *.

>>> list1 = ['Hello']

#elements of list1 repeated 4 times
>>> list1 * 4
['Hello', 'Hello', 'Hello', 'Hello']
VerakWorld

9.2.3 Membership VerakWorld

Like strings, the membership operators in and not in are used to check whether an element is present in a list.

Operator Meaning Result
in Checks whether an element is present. True if present, otherwise False.
not in Checks whether an element is not present. True if not present, otherwise False.
>>> list1 = ['Red','Green','Blue']

>>> 'Green' in list1
True

>>> 'Cyan' in list1
False

>>> 'Cyan' not in list1
True

>>> 'Green' not in list1
False
VerakWorld

9.2.4 Slicing VerakWorld

Like strings, slicing can also be applied to lists.

list[start : stop : step]
>>> list1 =['Red','Green','Blue','Cyan',
'Magenta','Yellow','Black']

>>> list1[2:6]
['Blue', 'Cyan', 'Magenta', 'Yellow']

#list1 is truncated to the end of the list
>>> list1[2:20]
['Blue', 'Cyan', 'Magenta', 'Yellow', 'Black']

#first index > second index
>>> list1[7:2]
[]

#return sublist from index 0 to 4
>>> list1[:5]
['Red','Green','Blue','Cyan','Magenta']

#slicing with a given step size
>>> list1[0:6:2]
['Red','Blue','Magenta']

#negative indexes
>>> list1[-6:-2]
['Green','Blue','Cyan','Magenta']

#both first and last index missing
>>> list1[::2]
['Red','Blue','Magenta','Black']

#negative step size
#whole list in the reverse order
>>> list1[::-1]
['Black','Yellow','Magenta','Cyan','Blue',
 'Green','Red']
VerakWorld
Exam Point: Slicing is used to extract a part of a list.

9.3 Traversing a List VerakWorld

We can access each element of a list or traverse a list using a for loop or a while loop.

(A) List Traversal Using for Loop VerakWorld

>>> list1 = ['Red','Green','Blue','Yellow','Black']

>>> for item in list1:
    print(item)

Output:
Red
Green
Blue
Yellow
Black
VerakWorld

Another way of accessing the elements of the list is by using range() and len() functions.

>>> for i in range(len(list1)):
    print(list1[i])

Output:
Red
Green
Blue
Yellow
Black
VerakWorld

(B) List Traversal Using while Loop VerakWorld

>>> list1 = ['Red','Green','Blue','Yellow','Black']

>>> i = 0
>>> while i < len(list1):
    print(list1[i])
    i += 1

Output:
Red
Green
Blue
Yellow
Black
VerakWorld

9.4 List Methods and Built-in Functions VerakWorld

The list data type has several built-in methods and functions useful for programming and list manipulation.

Method / Function Description Example / Important Point
len() Returns the length of the list passed as the argument.
>>> list1 = [10,20,30,40,50]
>>> len(list1)
5
list() Creates an empty list if no argument is passed. It creates a list if a sequence is passed as an argument.
>>> list1 = list()
>>> list1
[]

>>> str1 = 'aeiou'
>>> list1 = list(str1)
>>> list1
['a', 'e', 'i', 'o', 'u']
append() Appends a single element passed as argument at the end of the list. The single element can also be a list.
>>> list1 = [10,20,30,40]
>>> list1.append(50)
>>> list1
[10, 20, 30, 40, 50]

>>> list1 = [10,20,30,40]
>>> list1.append([50,60])
>>> list1
[10, 20, 30, 40, [50, 60]]
extend() Appends each element of the list passed as argument to the end of the given list.
>>> list1 = [10,20,30]
>>> list2 = [40,50]
>>> list1.extend(list2)
>>> list1
[10, 20, 30, 40, 50]
insert() Inserts an element at a particular index in the list.
>>> list1 = [10,20,30,40,50]
>>> list1.insert(2,25)
>>> list1
[10, 20, 25, 30, 40, 50]

>>> list1.insert(0,5)
>>> list1
[5, 10, 20, 25, 30, 40, 50]
count() Returns the number of times a given element appears in the list.
>>> list1 = [10,20,30,10,40,10]
>>> list1.count(10)
3

>>> list1.count(90)
0
index() Returns the index of the first occurrence of the element. If the element is not present, ValueError is generated.
>>> list1 = [10,20,30,20,40,10]
>>> list1.index(20)
1

>>> list1.index(90)
ValueError: 90 is not in list
remove() Removes the given element from the list. If the element is present multiple times, only the first occurrence is removed.
>>> list1 = [10,20,30,40,50,30]
>>> list1.remove(30)
>>> list1
[10, 20, 40, 50, 30]

>>> list1.remove(90)
ValueError:list.remove(x):x not in list
pop() Returns the element whose index is passed as parameter and also removes it. If no parameter is given, it removes the last element.
>>> list1 = [10,20,30,40,50,60]
>>> list1.pop(3)
40
>>> list1
[10, 20, 30, 50, 60]

>>> list1 = [10,20,30,40,50,60]
>>> list1.pop()
60
reverse() Reverses the order of elements in the given list.
>>> list1 = [34,66,12,89,28,99]
>>> list1.reverse()
>>> list1
[99, 28, 89, 12, 66, 34]

>>> list1 = ['Tiger','Zebra','Lion','Cat','Elephant','Dog']
>>> list1.reverse()
>>> list1
['Dog', 'Elephant', 'Cat', 'Lion', 'Zebra', 'Tiger']
sort() Sorts the elements of the given list in-place.
>>> list1 = ['Tiger','Zebra','Lion','Cat','Elephant','Dog']
>>> list1.sort()
>>> list1
['Cat', 'Dog', 'Elephant', 'Lion', 'Tiger', 'Zebra']

>>> list1 = [34,66,12,89,28,99]
>>> list1.sort(reverse = True)
>>> list1
[99,89,66,34,28,12]
sorted() Takes a list as parameter and creates a new list consisting of the same elements arranged in sorted order.
>>> list1 = [23,45,11,67,85,56]
>>> list2 = sorted(list1)
>>> list1
[23, 45, 11, 67, 85, 56]
>>> list2
[11, 23, 45, 56, 67, 85]
min() Returns minimum or smallest element of the list.
>>> list1 = [34,12,63,39,92,44]
>>> min(list1)
12
max() Returns maximum or largest element of the list.
>>> max(list1)
92
sum() Returns the sum of the elements of the list.
>>> sum(list1)
284
Exam Focus: Pay special attention to the difference between append() and extend(), and between sort() and sorted().

9.5 Nested Lists VerakWorld

When a list appears as an element of another list, it is called a nested list.

Example 9.2 VerakWorld
>>> list1 = [1,2,'a','c',[6,7,8],4,9]

#fifth element of list is also a list
>>> list1[4]
[6, 7, 8]

>>> list1[4][1]
7
VerakWorld
Nested List Structure VerakWorld
1
2
'a'
'c'
[6,7,8]
Nested list
4
9
Caption: A list appearing as an element of another list is a nested list.

To access an element of a nested list, two indices are specified: list1[i][j].

  • The first index i takes us to the desired nested list.
  • The second index j gives the desired element in that nested list.

9.6 Copying Lists VerakWorld

The simplest way to make a copy of a list is to assign it to another list.

>>> list1 = [1,2,3]
>>> list2 = list1

>>> list1
[1, 2, 3]

>>> list2
[1, 2, 3]
VerakWorld

The statement list2 = list1 does not create a new list. Instead, list1 and list2 refer to the same list object. Therefore, list2 becomes an alias of list1.

>>> list1.append(10)

>>> list1
[1, 2, 3, 10]

>>> list2
[1, 2, 3, 10]
VerakWorld
Exam Point: Assignment creates an alias, not a distinct list object.

Creating a Distinct Copy VerakWorld

The textbook gives three methods to create a copy or clone of a list as a distinct object:

  1. Using slicing
  2. Using the built-in list() function
  3. Using copy() from the Python copy library

Method 1 – Using Slicing VerakWorld

newList = oldList[:]
>>> list1 = [1,2,3,4,5]
>>> list2 = list1[:]
>>> list2
[1, 2, 3, 4, 5]
VerakWorld

Method 2 – Using list() VerakWorld

newList = list(oldList)
>>> list1 = [10,20,30,40]
>>> list2 = list(list1)
>>> list2
[10, 20, 30, 40]
VerakWorld

Method 3 – Using copy() VerakWorld

import copy

newList = copy.copy(oldList)
VerakWorld
>>> import copy
>>> list1 = [1,2,3,4,5]
>>> list2 = copy.copy(list1)
>>> list2
[1, 2, 3, 4, 5]
VerakWorld

9.7 List as Argument to a Function VerakWorld

Whenever a list is passed as an argument to a function, two scenarios need to be considered.

Scenario A – Elements of Original List May Be Changed VerakWorld

Changes made to the list inside the function are reflected back in the calling function.

When a list is passed as an argument, a reference to the list is passed. Therefore, changes made to the list inside the function can affect the actual list.

Program 9-1 VerakWorld

Program to increment the elements of a list. The list is passed as an argument to a function.

#Program 9-1
#Function to increment the elements of the list passed as argument
def increment(list2):
    for i in range(0,len(list2)):
        #5 is added to individual elements in the list
        list2[i] += 5
    print('Reference of list Inside Function',id(list2))
#end of function

list1 = [10,20,30,40,50] #Create a list
print("Reference of list in Main",id(list1))
print("The list before the function call")
print(list1)

increment(list1) #list1 is passed as parameter to function

print("The list after the function call")
print(list1)
VerakWorld
Output:

Reference of list in Main 70615968
The list before the function call
[10, 20, 30, 40, 50]
Reference of list Inside Function 70615968 #The id remains same
The list after the function call
[15, 25, 35, 45, 55]
VerakWorld

Scenario B – List Assigned a New Value Inside Function VerakWorld

If the list is assigned a new value inside the function, a new list object is created and it becomes the local copy of the function. Changes made inside the local copy are not reflected back in the calling function.

Program 9-2 VerakWorld

#Program 9-2
#Function to increment the elements of the list passed as argument
def increment(list2):
    print("\nID of list inside function before assignment:", id(list2))
    list2 = [15,25,35,45,55] #List2 assigned a new list
    print("ID of list changes inside function after assignment:", id(list2))
    print("The list inside the function after assignment is:")
    print(list2)
#end of function

list1 = [10,20,30,40,50] #Create a list
print("ID of list before function call:",id(list1))
print("The list before function call:")
print(list1)

increment(list1) #list1 passed as parameter to function

print('\nID of list after function call:',id(list1))
print("The list after the function call:")
print(list1)
VerakWorld
Output:

ID of list before function call: 65565640
The list before function call:
[10, 20, 30, 40, 50]
ID of list inside function before assignment:65565640
ID of list changes inside function after assignment:65565600
The list inside the function after assignment is:
[15, 25, 35, 45, 55]
ID of list after function call: 65565640
The list after the function call:
[10, 20, 30, 40, 50]
VerakWorld

9.8 List Manipulation VerakWorld

This chapter covers creating a list and different ways of manipulating lists. The following programs apply various list manipulation methods.

Program 9-3 – Menu Driven List Operations VerakWorld

The program performs the following operations:

  1. Append an element
  2. Insert an element
  3. Append a list to the given list
  4. Modify an existing element
  5. Delete an existing element from its position
  6. Delete an existing element with a given value
  7. Sort the list in ascending order
  8. Sort the list in descending order
  9. Display the list
#Program 9-3
#Menu driven program to do various list operations
myList = [22,4,16,38,13] #myList already has 5 elements
choice = 0

while True:
    print("The list 'myList' has the following elements", myList)
    print("\nL I S T O P E R A T I O N S")
    print(" 1. Append an element")
    print(" 2. Insert an element at the desired position")
    print(" 3. Append a list to the given list")
    print(" 4. Modify an existing element")
    print(" 5. Delete an existing element by its position")
    print(" 6. Delete an existing element by its value")
    print(" 7. Sort the list in ascending order")
    print(" 8. Sort the list in descending order")
    print(" 9. Display the list")
    print(" 10. Exit")

    choice = int(input("ENTER YOUR CHOICE (1-10): "))

    #append element
    if choice == 1:
        element = int(input("Enter the element to be appended: "))
        myList.append(element)
        print("The element has been appended\n")

    #insert an element at desired position
    elif choice == 2:
        element = int(input("Enter the element to be inserted: "))
        pos = int(input("Enter the position:"))
        myList.insert(pos,element)
        print("The element has been inserted\n")

    #append a list to the given list
    elif choice == 3:
        newList = eval(input("Enter the elements separated by commas"))
        myList.extend(list(newList))
        print("The list has been appended\n")

    #modify an existing element
    elif choice == 4:
        i = int(input("Enter the position of the element to be modified: "))
        if i < len(myList):
            newElement = int(input("Enter the new element: "))
            oldElement = myList[i]
            myList[i] = newElement
            print("The element",oldElement,"has been modified\n")
        else:
            print("Position of the element is more than the length of list")

    #delete an existing element by position
    elif choice == 5:
        i = int(input("Enter the position of the element to be deleted: "))
        if i < len(myList):
            element = myList.pop(i)
            print("The element",element,"has been deleted\n")
        else:
            print("\nPosition of the element is more than the length of list")

    #delete an existing element by value
    elif choice == 6:
        element = int(input("\nEnter the element to be deleted: "))
        if element in myList:
            myList.remove(element)
            print("\nThe element",element,"has been deleted\n")
        else:
            print("\nElement",element,"is not present in the list")

    #list in sorted order
    elif choice == 7:
        myList.sort()
        print("\nThe list has been sorted")

    #list in reverse sorted order
    elif choice == 8:
        myList.sort(reverse = True)
        print("\nThe list has been sorted in reverse order")

    #display the list
    elif choice == 9:
        print("\nThe list is:", myList)

    #exit from the menu
    elif choice == 10:
        break

    else:
        print("Choice is not valid")

    print("\n\nPress any key to continue..............")
    ch = input()
VerakWorld

Output – Program 9-3 VerakWorld

The list 'myList' has the following elements [22, 4, 16, 38, 13]
L I S T O P E R A T I O N S
1. Append an element
2. Insert an element at the desired position
3. Append a list to the given list
4. Modify an existing element
5. Delete an existing element by its position
6. Delete an existing element by its value
7. Sort the list in ascending order
8. Sort the list in descending order
9. Display the list
10. Exit

ENTER YOUR CHOICE (1-10): 8
The list has been sorted in reverse order

The list 'myList' has the following elements [38, 22, 16, 13, 4]
L I S T O P E R A T I O N S
1. Append an element
2. Insert an element at the desired position
3. Append a list to the given list
4. Modify an existing element
5. Delete an existing element by its position
6. Delete an existing element by its value
7. Sort the list in ascending order
8. Sort the list in descending order
9. Display the list
10. Exit
VerakWorld
ENTER YOUR CHOICE (1-10): 5
Enter the position of the element to be deleted: 2
The element 16 has been deleted

The list 'myList' has the following elements [38, 22, 13, 4]
L I S T O P E R A T I O N S
1. Append an element
2. Insert an element at the desired position
3. Append a list to the given list
4. Modify an existing element
5. Delete an existing element by its position
6. Delete an existing element by its value
7. Sort the list in ascending order
8. Sort the list in descending order
9. Display the list
10. Exit
VerakWorld

Program 9-4 – Average Marks VerakWorld

A program to calculate average marks of n students using a function where n is entered by the user.

#Program 9-4
#Function to calculate average marks of n students
def computeAverage(list1,n):
    #initialize total
    total = 0

    for marks in list1:
        #add marks to total
        total = total + marks

    average = total / n
    return average

#create an empty list
list1 = []

print("How many students marks you want to enter: ")
n = int(input())

for i in range(0,n):
    print("Enter marks of student",(i+1),":")
    marks = int(input())
    #append marks in the list
    list1.append(marks)

average = computeAverage(list1,n)
print("Average marks of",n,"students is:",average)
VerakWorld

Output – Program 9-4 VerakWorld

How many students marks you want to enter:
5

Enter marks of student 1:
45

Enter marks of student 2:
89

Enter marks of student 3:
79

Enter marks of student 4:
76

Enter marks of student 5:
55

Average marks of 5 students is: 68.8
VerakWorld

Program 9-5 – Linear Search VerakWorld

A user-defined function checks whether a number is present in the list. If present, it returns the position of the number.

#Program 9-5
#Function to check if a number is present in the list or not
def linearSearch(num,list1):
    for i in range(0,len(list1)):
        if list1[i] == num: #num is present
            return i #return the position

    return None #num is not present in the list
#end of function

list1 = [] #Create an empty list

print("How many numbers do you want to enter in the list: ")
maximum = int(input())

print("Enter a list of numbers: ")

for i in range(0,maximum):
    n = int(input())
    list1.append(n) #append numbers to the list

num = int(input("Enter the number to be searched: "))
result = linearSearch(num,list1)

if result is None:
    print("Number",num,"is not present in the list")
else:
    print("Number",num,"is present at",result + 1, "position")
VerakWorld

Output – Program 9-5 VerakWorld

How many numbers do you want to enter in the list:
5

Enter a list of numbers:
23
567
12
89
324

Enter the number to be searched:12

Number 12 is present at 3 position
VerakWorld

πŸ“ Exercise VerakWorld

1. What will be the output of the following statements? VerakWorld

i.
list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)

ii.
list1 = [12,32,65,26,80,10]
sorted(list1)
print(list1)

iii.
list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]

iv.
list1 = [1,2,3,4,5]
list1[len(list1)-1]
VerakWorld

2. Consider the following list myList. What will be the elements of myList after the following two operations? VerakWorld

myList = [10,20,30,40]

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

ii. myList.extend([80,90])
VerakWorld

3. What will be the output of the following code segment? VerakWorld

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])
VerakWorld

4. What will be the output of the following code segments? VerakWorld

a.
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)

b.
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)

c.
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)
VerakWorld

5. Differentiate between append() and extend() functions of list. VerakWorld

append() extend()
Appends a single element at the end of the list. Appends each element of the list passed as argument.
The appended element can itself be a list. The elements of the supplied list are added individually.

6. Consider a list: list1 = [6,7,8,9]. What is the difference between the following operations? VerakWorld

a. list1 * 2
b. list1 *= 2
c. list1 = list1 * 2
VerakWorld

7. Student Record VerakWorld

The record of a student containing Name, Roll No., Marks in five subjects and percentage is stored in the following list:

stRecord = ['Raman','A-36',[56,98,99,72,69],78.8]
VerakWorld

Write Python statements to retrieve:

  1. Percentage of the student
  2. Marks in the fifth subject
  3. Maximum marks of the student
  4. Roll no. of the student
  5. Change the name of the student from β€˜Raman’ to β€˜Raghav’

πŸ’» Programming Problems VerakWorld

  1. Write a program to find the number of times an element occurs in the list.
  2. Write 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.
  3. Write a function that returns the largest element of the list passed as parameter.
  4. Write a function to return the second largest number from a list of numbers.
  5. Write 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.
    Hint: You can use a built-in function to sort the list.
  6. Write 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 should appear only once.
  7. Write 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 has to be inserted. Write a user-defined function to insert the element at the desired position.
  8. Write a program to read elements of a list.
    1. Ask for the position of the element to be deleted from the list. Write a function to delete the element at the desired position.
    2. Ask for the value of the element to be deleted from the list. Write a function to delete the element of this value.
  9. Read a list of n elements. Pass this list to a function which reverses this list in-place without creating a new list.

πŸ“ Important Questions & Answers VerakWorld

1. What is a list in Python? VerakWorld
A list is an ordered, mutable sequence containing one or more elements. Its elements are enclosed in square brackets and separated by commas.
2. Why are lists called mutable? VerakWorld
Lists are called mutable because their contents can be changed after the list has been created.
3. From which index does list indexing start? VerakWorld
List indexing starts from 0.
4. What is concatenation of lists? VerakWorld
Concatenation is joining two or more lists using the + operator.
5. Which operator is used for list repetition? VerakWorld
The * operator is used for list repetition.
6. What are membership operators used with lists? VerakWorld
The membership operators are in and not in.
7. What is slicing? VerakWorld
Slicing is used to extract a part of a list.
8. What is a nested list? VerakWorld
A list appearing as an element of another list is called a nested list.
9. How can a nested-list element be accessed? VerakWorld
A nested-list element can be accessed using two indices in the form list1[i][j].
10. What is the difference between list1 = list2 type assignment and making a copy? VerakWorld
Assignment makes the two variables refer to the same list object, whereas slicing, list(), or copy.copy() can create a distinct copy.
11. What does append() do? VerakWorld
It appends a single element at the end of the list.
12. What does extend() do? VerakWorld
It appends each element of the list passed as an argument to the end of the given list.
13. What does insert() do? VerakWorld
It inserts an element at a particular index in the list.
14. What does count() return? VerakWorld
It returns the number of times a given element appears in the list.
15. What does index() return? VerakWorld
It returns the index of the first occurrence of the specified element.
16. What does remove() do? VerakWorld
It removes the given element from the list. If it occurs multiple times, only the first occurrence is removed.
17. What does pop() do? VerakWorld
It returns and removes the element at the specified index. Without a parameter, it returns and removes the last element.
18. What does reverse() do? VerakWorld
It reverses the order of elements in the list.
19. What is the difference between sort() and sorted()? VerakWorld
sort() sorts the given list in-place, while sorted() creates a new sorted list.
20. Name the three methods given in the chapter to create a distinct copy of a list. VerakWorld
Slicing, the list() function, and copy.copy().

⚑ Quick Revision VerakWorld

Important Definitions VerakWorld
  • List: An ordered and mutable sequence of elements.
  • Mutable: The contents of a list can be changed after creation.
  • Nested List: A list appearing as an element of another list.
  • Slicing: Extracting a part of a list.
  • Concatenation: Joining lists using +.
Important Operators VerakWorld
Operator Use
+ Concatenation
* Repetition
in Checks whether an element is present
not in Checks whether an element is not present
Important List Functions / Methods VerakWorld
Function / Method Purpose
len()Returns length of list
list()Creates a list
append()Adds one element at end
extend()Adds elements of another list
insert()Inserts element at index
count()Counts occurrences
index()Returns first occurrence index
remove()Removes given element
pop()Returns and removes element
reverse()Reverses list
sort()Sorts list in-place
sorted()Creates a new sorted list
min()Smallest element
max()Largest element
sum()Sum of elements
Important Syntax / Examples VerakWorld
list1[index]

list1[start:stop]

list1[start:stop:step]

list1 + list2

list1 * n

element in list1

element not in list1

list1.append(element)

list1.extend(list2)

list1.insert(index,element)

list1.remove(element)

list1.pop(index)

list1.reverse()

list1.sort()

sorted(list1)
VerakWorld
Last-Minute Exam Revision:
  • Remember that list indexing starts from 0.
  • Remember that lists are mutable.
  • Learn positive and negative indexing.
  • Practise list slicing.
  • Understand append() vs extend().
  • Understand sort() vs sorted().
  • Learn nested-list indexing.
  • Remember the three distinct-copy methods.
  • Practise passing lists to functions.
  • Practise the five programs given in the chapter.
  • Practise all textbook exercises and programming problems.

🎯 Exam-Oriented Important Questions VerakWorld

1-Mark / Very Short Questions VerakWorld

  1. What is a list?
  2. From which index does a list start?
  3. Are lists mutable?
  4. Which brackets are used to represent a list?
  5. Which operator is used for concatenation?
  6. Which operator is used for repetition?
  7. Name the membership operators.
  8. What is a nested list?
  9. What does len() return?
  10. What does append() do?
  11. What does extend() do?
  12. What does count() return?
  13. What does index() return?
  14. What does reverse() do?
  15. What does sort() do?
  16. What does sorted() return?

Short-Answer Questions VerakWorld

  1. Explain the characteristics of a Python list.
  2. Explain accessing elements in a list with examples.
  3. Explain why lists are mutable.
  4. Explain concatenation and repetition operations.
  5. Explain membership operators with examples.
  6. Explain list slicing with examples.
  7. Explain list traversal using a for loop.
  8. Explain list traversal using a while loop.
  9. Explain the important list methods and built-in functions.
  10. Explain nested lists with an example.
  11. Explain copying lists and aliases.
  12. Explain the three methods of creating a distinct copy of a list.
  13. Explain how a list behaves when passed as an argument to a function.
  14. Differentiate between append() and extend().
  15. Differentiate between sort() and sorted().

Programming / Practical Questions VerakWorld

  1. Write a program to find the number of times an element occurs in a list.
  2. Write a program to separate positive and negative numbers into two lists.
  3. Write a function to return the largest element of a list.
  4. Write a function to return the second largest number.
  5. Write a program to find the median of a list.
  6. Write a program to remove duplicate elements from a list.
  7. Write a function to insert an element at a desired position.
  8. Write functions to delete an element by position and by value.
  9. Write a function to reverse a list in-place.

βœ… Final Revision VerakWorld

Chapter 9 focuses on Python Lists, including creation, indexing, mutability, list operations, traversal, list methods and built-in functions, nested lists, copying lists, passing lists to functions and list manipulation.

For examination preparation, concentrate especially on definitions, indexing, slicing, list operators, list methods, append versus extend, sort versus sorted, nested-list indexing, copying lists, function arguments, textbook programs, exercises and programming problems.

Complete the textbook exercises and practise the programs before the examination.
Β© VerakWorld | Educational Notes VerakWorld

πŸ“ This article was researched and written by Venkatesh A, Founder of verakworld.com.

Leave a Comment