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?
- (7)
- (7,)
- [7]
- 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?
- t + (4,)
- t[1:]
- t.count(2)
- 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, 2, 3, 4, 5] [1, 2, 3, 4, 5]
- [1, 2, 3, 4] [1, 2, 3, 5]
- [1, 2, 3, 4] [1, 2, 3, 4, 5]
- [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
- What does this slice of the list marks print?
- One value is appended and another inserted at the front of a list. What is…
- Which expression creates a tuple containing the single element 7?
- Three facts about a tuple of scores are printed. What is the output?
- A list is appended to another list. What length does this print?
- An element of a tuple is assigned a new value. What happens?
- Two variables are exchanged using tuple packing and unpacking. What is printed?
- The same list goes through sorted() and then sort(). What does this print?
- One name is a slice copy of the list a and another is a plain assignment. What…
- remove() and pop() are used on a queue of token numbers. What does this print?
- A starred name is used while unpacking a list. What is printed?
- For the tuple t = (1, 2, 3), which of these operations is NOT allowed?
- A marks table is stored as a list of rows. What does this print?
- Kavya has a list a and wants b to be a separate list with the same items, so…
- A two-element slice of a list is replaced by a one-element list. What is…
- The list a is extended once with + and once with += through a second name…
- Even numbers are removed from a list while a for loop is running over it. What…
- Student records are sorted by marks in descending order using a key. In what…
- Two slices with negative values are taken from a list. What does this print?
- Tuples of different lengths are compared. What does this print?
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
- Variables, Types & Operators: Dynamic typing, numbers, operators, precedence and truthiness.
- Python Strings: Indexing, slicing, methods, formatting and immutability.
- Dictionaries & Sets: Lookups, iteration, hashable keys and set operations.
- Conditions & Loops: if/elif, for, while, range, break, continue and loop else.
- Functions & Scope: Arguments, defaults, *args, closures, lambda and recursion.
- Comprehensions & Generators: List, dict and set comprehensions, yield and lazy evaluation.
- Classes & Objects: Attributes, inheritance, super(), dunder methods and properties.
- Exceptions & Files: try/except/else/finally, raising errors and the with statement.
- Built-ins & Standard Library: sorted, zip, any/all, collections, itertools and imports.
Other subjects
- Quantitative Aptitude: Arithmetic, percentages, time and work, speed, probability and data interpretation: the numerical section of every fresher test.
- Logical Reasoning: Series, coding-decoding, arrangements, syllogisms and puzzles: the section that separates prepared candidates from the rest.
- Verbal Ability: Vocabulary, grammar, reading comprehension and sentence order: tested in nearly every IT services hiring exam.
- Technical & Programming: CS fundamentals, output prediction and pseudo-code: the technical MCQ round for IT roles.
- SQL: SQL quizzes by topic, from SELECT and joins to window functions: query output and concepts for analyst and developer roles.
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