(Strictly based on NCERT Textbook)
1. Which of the following statements about Python lists is correct?
(a) Lists are immutable sequences
(b) Lists can contain elements of only one data type
(c) Elements of a list are enclosed in square brackets
(d) List indices start from 1
2. What will be the output of the following code?
python
list1 = [10, 20, 30, 40]
print(list1[-2])
(a) 20 (b) 30 (c) 40 (d) Error
3. Which operator is used to concatenate two lists?
(a) * (b) + (c) & (d) ,
4. The statement list1 = list1 + [50] will:
(a) Modify list1 in-place
(b) Create a new list and assign it to list1
(c) Raise TypeError
(d) Return None
5. Which of the following creates a shallow copy of a list?
(a) newList = oldList
(b) newList = oldList[:]
(c) newList = oldList + []
(d) Both (b) and (c)
6. Assertion (A): The append() method can add a list as a single element to another list.
Reason (R): extend() adds each element of the passed list individually to the end of the given list.
(a) Both A and R are true and R is the correct explanation of A
(b) Both A and R are true but R is not the correct explanation of A
(c) A is true but R is false
(d) A is false but R is true
7. Assertion (A): When a list is passed as an argument to a function, changes made inside the function are reflected in the original list.
Reason (R): Lists are passed by reference in Python.
(a) Both A and R are true and R is the correct explanation of A
(b) Both A and R are true but R is not the correct explanation of A
(c) A is true but R is false
(d) A is false but R is true
8. What is the result of list1 = [1,2,3]; print(list1 * 2)?
(a) [2, 4, 6] (b) [1,2,3,1,2,3] (c) Error (d) [1,1,2,2,3,3]
9. Which method removes the element at a given index and returns it?
(a) remove() (b) pop() (c) delete() (d) clear()
10. The expression list1[::−1] on a list performs:
(a) Sorting in descending order
(b) Reversing the list
(c) Slicing with step 1
(d) Creating an empty list
1. Define a list. State any two characteristics of lists as mentioned in the NCERT chapter.
2. Differentiate between list1.append([50,60]) and list1.extend([50,60]) with respect to the final content of list1.
3. What will be the output?
python
list1 = ['Red','Green','Blue']
print('Cyan' in list1)
print('Green' not in list1)
4. Write the output of the following:
python
list1 = [10,20,30,40,50]
print(list1[2:5])
print(list1[: : 2])
5. What is a nested list? How can an element of a nested list be accessed? Give one example from the chapter.
6. State the difference between list1.sort() and sorted(list1).
1. Write the output of the following code fragment and explain:
python
list1 = [34,66,12,89,28,99]
list1.reverse()
print(list1)
list2 = sorted(list1)
print(list2)
2. Identify the error in the following code and write the corrected version:
python
list1 = [10,20,30]
list1 = list1 + "40"
print(list1)
3. What will be the output?
python
myList = [10,20,30,40]
myList.append([50,60])
print(myList)
myList.extend([80,90])
print(myList)
4. Write a short code fragment using while loop to traverse and print all elements of a list (as shown in NCERT).
5. Explain with an example why list2 = list1 does not create a separate copy of the list.
1. Write a complete Python program that reads n integers from the user, stores them in a list, and then prints:
- The original list
- The list sorted in ascending order
- The list sorted in descending order
- The sum and average of the elements
(Use appropriate list methods.)
2. Explain with a dry-run (trace table) how the following code works when the list [10, 20, 30, 40, 50] is passed to the function:
```python
def increment(list2):
for i in range(len(list2)):
list2[i] += 5
return list2
list1 = [10, 20, 30, 40, 50] print(increment(list1)) print(list1) ```
3. Write a user-defined function linearSearch(num, list1) that returns the position (1-based) of num if found in the list, otherwise returns None. Also write the calling code to accept a list of numbers and search for an element.
A school wants to maintain a list of marks obtained by students in a class test. The teacher creates the following list:
marks = [45, 67, 89, 34, 78, 56, 92]
Answer the following:
(a) Write a statement to append the mark of a new student (75).
(b) Write a statement to insert 88 at index 3.
(c) Write code to find and print the highest and lowest marks using built-in functions.
(d) Write a loop to count how many students scored more than 70.
A program is written to manipulate a list of colours. The initial list is:
colours = ['Red', 'Green', 'Blue', 'Yellow']
Answer the following:
(a) What will be the output of colours[1:3]?
(b) Write statements to replace 'Yellow' with 'Black' using mutability.
(c) Write code to create a true copy of the list using the slicing method.
(d) What happens if we do newColours = colours and then modify newColours? Explain.
append([50,60]) adds the list as a single element → [..., [50,60]]; extend([50,60]) adds elements individually → [..., 50, 60]. list1[4][1]. sort() sorts the list in-place; sorted() returns a new sorted list without modifying the original.Output:
[99, 28, 89, 12, 66, 34]
[12, 28, 34, 66, 89, 99]
(reverse() reverses in-place; sorted() returns new list)
Error: TypeError: can only concatenate list (not "str") to list
Corrected: list1 = list1 + [40]
[10, 20, 30, 40, [50, 60]]
[10, 20, 30, 40, [50, 60], 80, 90]
(Any correct while loop traversal as per NCERT 9.3)
list2 = list1 makes list2 an alias of list1. Both refer to the same object; changes in one are reflected in the other.
append(), sort(), sum(), len() etc.)python
n = int(input("Enter number of elements: "))
lst = []
for i in range(n):
lst.append(int(input()))
print("Original:", lst)
lst.sort()
print("Ascending:", lst)
lst.sort(reverse=True)
print("Descending:", lst)
print("Sum:", sum(lst), "Average:", sum(lst)/n)
Trace table shows same id() before and after function call; elements are modified in-place because list is passed by reference.
Function as per Program 9-5 of NCERT.
(a) marks.append(75)
(b) marks.insert(3, 88)
(c) print(max(marks), min(marks))
(d) Counter loop using for or while
(a) ['Green', 'Blue']
(b) colours[3] = 'Black'
(c) newList = colours[:]
(d) Both variables refer to the same list object; modification affects both (aliasing).
All questions are answerable from the NCERT chapter text. Reviewed by GFIS faculty.