Sunday, September 13, 2026

Python List Method Quiz

Python List Method Quiz


1. What is the output? x = [1, 2] x.append(3) print(x)

   A. [3, 1, 2]

   B. [1, 3, 2]

   C. [1, 2]

   D. [1, 2, 3]


2. What is the output? x = [1, 2] x.extend([3, 4]) print(x)

   A. [1, 2]

   B. [3, 4, 1, 2]

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

   D. [1, 2, 3, 4]


3. What is the output? x = [10, 20, 30] x.insert(1, 99) print(x)

   A. [99, 10, 20, 30]

   B. [10, 20, 30, 99]

   C. [10, 20, 99, 30]

   D. [10, 99, 20, 30]


4. What is the output? x = [1, 2, 2, 3] x.remove(2) print(x)

   A. [1, 3]

   B. [1, 2, 2]

   C. [1, 2, 3]

   D. [2, 2, 3]


5. What is the output? x = [10, 20, 30] y = x.pop() print(y, x)

   A. 30 [10, 20, 30]

   B. 10 [20, 30]

   C. 30 [10, 20]

   D. 20 [10, 30]


6. What is the output? x = [1, 2, 3] x.pop(0) print(x)

   A. [2, 3]

   B. [1, 3]

   C. [1, 2, 3]

   D. [1, 2]


7. What is the output? x = [1, 2, 3] x.clear() print(x)

   A. [3]

   B. None

   C. [1]

   D. []


8. What is the output? x = [10, 20, 30, 20] print(x.index(20))

   A. 0

   B. 3

   C. 1

   D. 2


9. What is the output? x = [1, 2, 2, 3, 2] print(x.count(2))

   A. 1

   B. 2

   C. 3

   D. 4


10. What is the output? x = [3, 1, 2] x.sort() print(x)

   A. [3, 2, 1]

   B. [2, 1, 3]

   C. [3, 1, 2]

   D. [1, 2, 3]


11. What is the output? x = [1, 2, 3] x.reverse() print(x)

   A. [1, 3, 2]

   B. [1, 2, 3]

   C. [3, 2, 1]

   D. [2, 3, 1]


12. What is the output? x = [1, 2] y = x.copy() y.append(3) print(x)

   A. [1, 2, 3]

   B. [1, 2]

   C. []

   D. [3, 1, 2]


13. What is the output? x = [1, 2] x += [3, 4] print(x)

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

   B. [1, 2]

   C. [3, 4, 1, 2]

   D. [1, 2, 3, 4]


14. What is the output? x = [1, 2] x.append([3, 4]) print(x)

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

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

   C. [1, 2, 3, 4]

   D. [1, 2]


15. What is the output? x = [5, 10, 15] print(x.pop(1))

   A. 1

   B. 5

   C. 10

   D. 15


16. What is the output? x = [4, 1, 3] y = x.sort() print(y)

   A. 3

   B. [1, 3, 4]

   C. [4, 1, 3]

   D. None


17. What is the output? x = [1, 2, 3] y = x.reverse() print(y)

   A. 3

   B. [3, 2, 1]

   C. None

   D. [1, 2, 3]


18. What is the output? x = [1, 2, 3] x.insert(0, 9) print(x)

   A. [9, 1, 2, 3]

   B. [1, 2, 9, 3]

   C. [1, 2, 3, 9]

   D. [1, 9, 2, 3]


19. What is the output? x = [1, 2, 3] x.remove(2) print(x)

   A. [1, 2]

   B. [2, 3]

   C. [1, 2, 3]

   D. [1, 3]


20. What is the output? x = [3, 1, 2] x.sort(reverse=True) print(x)

   A. [3, 1, 2]

   B. [2, 3, 1]

   C. [3, 2, 1]

   D. [1, 2, 3]

2 comments:

Purandaran said...

What is the output?

x = \[1, 2\] x.append(3) print(x)

append adds the single value 3 to the end of the list.

What is the output?

x = \[1, 2\] x.extend(\[3, 4\]) print(x)

extend adds 3 and 4 as separate elements to the end of x.

What is the output?

x = \[10, 20, 30\] x.insert(1, 99) print(x)

insert at index 1 places 99 before the original element at index 1.

What is the output?

x = \[1, 2, 2, 3\] x.remove(2) print(x)

remove deletes the first occurrence of the specified value.

What is the output?

x = \[10, 20, 30\] y = x.pop() print(y, x)

pop with no index removes and returns the last element.

What is the output?

x = \[1, 2, 3\] x.pop(0) print(x)

Index 0 contains 1, so removing it leaves 2 and 3.

What is the output?

x = \[1, 2, 3\] x.clear() print(x)

clear removes all elements from the existing list.

What is the output?

x = \[10, 20, 30, 20\] print(x.index(20))

index returns the position of the first matching value, and 20 first appears at index 1.

What is the output?

x = \[1, 2, 2, 3, 2\] print(x.count(2))

count returns the number of times the specified value occurs.

What is the output?

x = \[3, 1, 2\] x.sort() print(x)

sort orders the numeric elements in ascending order by default.

What is the output?

x = \[1, 2, 3\] x.reverse() print(x)

reverse changes the list order to the opposite sequence.

What is the output?

x = \[1, 2\] y = x.copy() y.append(3) print(x)

copy creates a separate list object, so appending to y does not change x.

What is the output?

x = \[1, 2\] x += \[3, 4\] print(x)

List concatenation with += adds the elements of the right-hand list to x.

What is the output?

x = \[1, 2\] x.append(\[3, 4\]) print(x)

append adds its argument as a single element at the end.

What is the output?

x = \[5, 10, 15\] print(x.pop(1))

Index 1 contains 10, so pop(1) returns that value.

What is the output?

x = \[4, 1, 3\] y = x.sort() print(y)

The list is sorted in place, and the return value of sort is None.

What is the output?

x = \[1, 2, 3\] y = x.reverse() print(y)

reverse modifies the list in place and its return value is None.

What is the output?

x = \[1, 2, 3\] x.insert(0, 9) print(x)

Index 0 is the first position, so 9 is inserted before the existing elements.

What is the output?

x = \[1, 2, 3\] x.remove(2) print(x)

remove(2) deletes the element whose value is 2.

What is the output?

x = \[3, 1, 2\] x.sort(reverse=True) print(x)

reverse=True makes sort arrange the numeric values in descending order.

Anonymous said...

What is the output?

x = \[1, 2\] x.append(3) print(x)

append adds the single value 3 to the end of the list.

What is the output?

x = \[1, 2\] x.extend(\[3, 4\]) print(x)

extend adds 3 and 4 as separate elements to the end of x.

What is the output?

x = \[10, 20, 30\] x.insert(1, 99) print(x)

insert at index 1 places 99 before the original element at index 1.

What is the output?

x = \[1, 2, 2, 3\] x.remove(2) print(x)

remove deletes the first occurrence of the specified value.

What is the output?

x = \[10, 20, 30\] y = x.pop() print(y, x)

pop with no index removes and returns the last element.

What is the output?

x = \[1, 2, 3\] x.pop(0) print(x)

Index 0 contains 1, so removing it leaves 2 and 3.

What is the output?

x = \[1, 2, 3\] x.clear() print(x)

clear removes all elements from the existing list.

What is the output?

x = \[10, 20, 30, 20\] print(x.index(20))

index returns the position of the first matching value, and 20 first appears at index 1.

What is the output?

x = \[1, 2, 2, 3, 2\] print(x.count(2))

count returns the number of times the specified value occurs.

What is the output?

x = \[3, 1, 2\] x.sort() print(x)

sort orders the numeric elements in ascending order by default.

What is the output?

x = \[1, 2, 3\] x.reverse() print(x)

reverse changes the list order to the opposite sequence.

What is the output?

x = \[1, 2\] y = x.copy() y.append(3) print(x)

copy creates a separate list object, so appending to y does not change x.

What is the output?

x = \[1, 2\] x += \[3, 4\] print(x)

List concatenation with += adds the elements of the right-hand list to x.

What is the output?

x = \[1, 2\] x.append(\[3, 4\]) print(x)

append adds its argument as a single element at the end.

What is the output?

x = \[5, 10, 15\] print(x.pop(1))

Index 1 contains 10, so pop(1) returns that value.

What is the output?

x = \[4, 1, 3\] y = x.sort() print(y)

The list is sorted in place, and the return value of sort is None.

What is the output?

x = \[1, 2, 3\] y = x.reverse() print(y)

reverse modifies the list in place and its return value is None.

What is the output?

x = \[1, 2, 3\] x.insert(0, 9) print(x)

Index 0 is the first position, so 9 is inserted before the existing elements.

What is the output?

x = \[1, 2, 3\] x.remove(2) print(x)

remove(2) deletes the element whose value is 2.

What is the output?

x = \[3, 1, 2\] x.sort(reverse=True) print(x)

reverse=True makes sort arrange the numeric values in descending order.