Lists & Tuples questions and answers

Slicing, methods, copies, sorting and unpacking. Practise lists & tuples questions from the python section of placement tests, with a worked explanation after every answer. Practice is free and needs no sign-up.

Sample lists & tuples questions with worked answers

Question 1

Which expression creates a tuple containing the single element 7?

  1. (7)
  2. (7,)
  3. [7]
  4. tuple(7)

Answer: B. (7,)

Explanation: The comma makes the tuple, not the brackets, so (7,) is a one-element tuple. (7) is just the integer 7, [7] is a list, and tuple(7) raises TypeError because an integer is not iterable.

Question 2

For the tuple t = (1, 2, 3), which of these operations is NOT allowed?

  1. t + (4,)
  2. t[1:]
  3. t.count(2)
  4. t.append(4)

Answer: D. t.append(4)

Explanation: A tuple cannot be changed after creation, so it has no append() method. Concatenation and slicing build new tuples, and count() only reads the tuple, so all three are allowed.

Question 3

The list a is extended once with + and once with += through a second name. What does this print?

a = [1, 2, 3]
b = a
a = a + [4]
b += [5]
print(a, b)
  1. [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]
  2. [1, 2, 3, 4] [1, 2, 3, 5]
  3. [1, 2, 3, 4] [1, 2, 3, 4, 5]
  4. [1, 2, 3, 4, 5] [1, 2, 3, 5]

Answer: B. [1, 2, 3, 4] [1, 2, 3, 5]

Explanation: a + [4] creates a brand new list and a is rebound to it, so b still refers to the original [1, 2, 3]. b += [5] then extends that original list in place, which no longer affects a.

All 20 lists & tuples questions with answers

Lists & Tuples: common questions

What are lists & tuples questions?

Slicing, methods, copies, sorting and unpacking. They appear in the python section of many placement tests.

Where can I practise lists & tuples questions with answers for free?

Right here on LogicWiz Exams. Every lists & tuples question has a worked explanation after you answer. Practice is free and needs no sign-up.

How should I practise lists & tuples?

Start with easy questions, then move to medium and hard. Read the explanation after each answer, and come back to the ones you missed.

Start practising

On this page you can start a fresh set of lists & tuples questions, choose easy, medium or hard, and time yourself if you want to. Or practise the whole subject: Python practice.

More python topics

Other subjects

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge · Test from a job description · LogicWiz Open: free team quiz · Free interview prep