Exit Chapter 06 ยท ๐Ÿ“‹ List Manipulation โ€” Quiz

Playing as a guest? to earn XP and track your progress.

Question 1 of 58 0 correct so far

๐Ÿ“‹ List Manipulation Quiz

Q1.

A list in Python is written inside:

Explanation

Example: marks = [45, 78, 92].

Q2.

Which statement about lists is TRUE?

Explanation

Lists keep their order, can be changed, allow duplicates and can mix types.

Q3.

Can a list contain items of different data types, like [1, "two", 3.0]?

Explanation

A list can hold items of any type.

Q4.

Which statement creates an EMPTY list?

Explanation

[] (or list()) creates an empty list.

Q5.

What is the output of:

print(list("abc"))
Explanation

list() on a string makes a list of its characters.

Q6.

What is the output of:

print(list(range(4)))
Explanation

range(4) gives 0, 1, 2, 3.

Q7.

L = [10, 20, 30, 40]. What is L[1]?

Explanation

Indexing starts at 0, so index 1 is the second item.

Q8.

L = [10, 20, 30, 40]. What is L[-1]?

Explanation

Negative index โˆ’1 means the last item.

Q9.

L = [10, 20, 30, 40]. What is L[-3]?

Explanation

Counting from the right: โˆ’1 is 40, โˆ’2 is 30, โˆ’3 is 20.

Q10.

L = [10, 20, 30]. What does L[3] give?

Explanation

Valid indexes are 0, 1 and 2 only.

Q11.

For a list of 6 items, what is the index of the LAST item?

Explanation

Indexes go from 0 to length โˆ’ 1.

Q12.

What is the output of:

L = [1, 2, 3]
L[1] = 9
print(L)
Explanation

Lists are mutable, so L[1] can be changed.

Q13.

L = [5, 10, 15, 20, 25]. What is L[1:4]?

Explanation

The slice includes the start index and stops before the stop index.

Q14.

L = [5, 10, 15, 20, 25]. What is L[:2]?

Explanation

No start means from the beginning.

Q15.

L = [5, 10, 15, 20, 25]. What is L[2:]?

Explanation

No stop means till the end.

Q16.

L = [5, 10, 15, 20, 25]. What is L[::2]?

Explanation

Step 2 takes every second item.

Q17.

L = [1, 2, 3, 4]. What is L[::-1]?

Explanation

A step of โˆ’1 gives the list in reverse.

Q18.

L = [1, 2, 3]. What is L[1:10]?

Explanation

Slicing never gives an IndexError; it stops at the end of the list.

Q19.

L = [10, 20, 30, 40, 50]. What is L[-3:-1]?

Explanation

โˆ’3 is 30 and โˆ’1 is 50; the slice stops before 50.

Q20.

What is the output of:

print([1, 2] + [3, 4])
Explanation
  • joins (concatenates) two lists.
Q21.

What is the output of:

print([0] * 3)
Explanation

* repeats the list.

Q22.

What does [1, 2, 3] + 4 give?

Explanation

Only a list can be joined to a list.

Q23.

What is the output of:

print(3 in [1, 2, 3])
Explanation

in checks whether the value is in the list.

Q24.

What is the output of:

print(len([4, 5, [6, 7]]))
Explanation

The inner list [6, 7] counts as ONE item.

Q25.

What is the output of:

for x in [2, 4, 6]:
    print(x * 2, end=" ")
Explanation

Each item is doubled and printed.

Q26.

Which loop visits every INDEX of list L?

Explanation

range(len(L)) gives 0 to len(L) โˆ’ 1.

Q27.

What is the output of:

L = [1, 2]
L.append(3)
print(L)
Explanation

append() adds one item at the end.

Q28.

What is the output of:

L = [1, 2]
L.append([3, 4])
print(L)
Explanation

append() adds the whole list as ONE item.

Q29.

What is the output of:

L = [1, 2]
L.extend([3, 4])
print(L)
Explanation

extend() adds each item of the given list.

Q30.

What is the output of:

L = [10, 30]
L.insert(1, 20)
print(L)
Explanation

insert(1, 20) puts 20 at index 1.

Q31.

Which method adds one item at a GIVEN position?

Explanation

insert(index, item) places the item at that index.

Q32.

What is the output of:

L = [5, 6, 7]
x = L.pop()
print(x, L)
Explanation

pop() without an index removes and returns the last item.

Q33.

What is the output of:

L = [5, 6, 7]
L.pop(0)
print(L)
Explanation

pop(0) removes the item at index 0.

Q34.

What is the output of:

L = [3, 1, 3, 2]
L.remove(3)
print(L)
Explanation

remove() deletes only the FIRST occurrence of the value.

Q35.

What does L.remove(9) do if 9 is not in L?

Explanation

remove() raises ValueError if the value is not found.

Q36.

Which statement removes the item at index 2 from list L?

Explanation

del L[2] deletes by position; remove(2) would delete the VALUE 2.

Q37.

What is the output of:

L = [1, 2, 3]
L.clear()
print(L)
Explanation

clear() removes all items, leaving an empty list.

Q38.

pop() and remove() differ because:

Explanation

pop(i) uses an index; remove(x) uses a value.

Q39.

What is the output of:

print([1, 2, 1, 1].count(1))
Explanation

count() tells how many times a value appears.

Q40.

What is the output of:

print([4, 8, 8, 2].index(8))
Explanation

index() gives the position of the FIRST occurrence.

Q41.

What is the output of:

L = [3, 1, 2]
L.sort()
print(L)
Explanation

sort() arranges the list in ascending order in place.

Q42.

What is the output of:

L = [3, 1, 2]
L.sort(reverse=True)
print(L)
Explanation

reverse=True sorts in descending order.

Q43.

What is the output of:

L = [3, 1, 2]
print(L.sort())
Explanation

sort() changes the list in place and returns None.

Q44.

What is the output of:

L = [3, 1, 2]
M = sorted(L)
print(L, M)
Explanation

sorted() returns a NEW sorted list and leaves the original unchanged.

Q45.

What is the output of:

L = [1, 5, 3]
L.reverse()
print(L)
Explanation

reverse() reverses the order of items; it does not sort them.

Q46.

L = [4, 9, 2, 7]. What is max(L) + min(L)?

Explanation

max is 9, min is 2, and 9 + 2 = 11.

Q47.

L = [10, 20, 30]. What is sum(L) / len(L)?

Explanation

Average = 60 / 3 = 20.0 (/ gives a float).

Q48.

What is the output of:

print(max(["apple", "mango", "banana"]))
Explanation

Strings are compared alphabetically; m comes last.

Q49.

A list that contains another list as an item is called a:

Explanation

Example: [[1, 2], [3, 4]].

Q50.

L = [[1, 2], [3, 4], [5, 6]]. What is L[1][0]?

Explanation

L[1] is [3, 4], and its index 0 is 3.

Q51.

L = [[1, 2], [3, 4], [5, 6]]. What is L[-1][-1]?

Explanation

The last inner list is [5, 6], and its last item is 6.

Q52.

What is the output of:

L = [12, 45, 7, 30]
big = L[0]
for x in L:
    if x > big:
        big = x
print(big)
Explanation

The loop keeps the largest value seen so far.

Q53.

What is the output of:

L = [3, 8, 5, 6]
c = 0
for x in L:
    if x % 2 == 0:
        c += 1
print(c)
Explanation

8 and 6 are even.

Q54.

Searching for a value by checking every item one by one is called:

Explanation

Linear search checks each element from the start until it finds the value.

Q55.

What is the output of:

A = [1, 2]
B = A
B.append(3)
print(A)
Explanation

B = A does not copy the list; both names refer to the SAME list.

Q56.

What is the output of:

print([1, 2, 3] == [1, 2, 3])
Explanation

Lists with the same items in the same order are equal.

Q57.

What is the output of:

print([1, 2] < [1, 3])
Explanation

Lists are compared item by item; 2 < 3.

Q58.

Which of these is NOT a list method?

Explanation

Python lists have no push() method; use append().