AP Computer Science Principles Quiz: Lists
20 questions · exam conditions
0:00
ListsQuestion 1 of 20

Which of the following best explains why lists are considered a form of data abstraction?

Lists hide the complexity of memory management and provide simple operations for data manipulation
Lists automatically encrypt stored data to protect sensitive information from unauthorized system access
Lists convert all data types to a universal format for improved compatibility across platforms
Lists compress data to reduce storage requirements and optimize overall system performance characteristics
← Back to quizzes

AP Computer Science Principles Quiz

AP Computer Science Principles Quiz: Lists

Practice Lists in AP Computer Science Principles with focused quiz questions that help you check what you know, review explanations, and build confidence with test-style prompts.

What this quiz covers

This quiz focuses on Lists, giving you a quick way to practice the rules, question types, and explanations that matter most for AP Computer Science Principles.

How to use this quiz

Try each quiz question before looking at the correct answer. Use the explanations to review missed ideas, then come back to similar questions until the pattern feels familiar.

All questions

Question 1

Which of the following best explains why lists are considered a form of data abstraction?

  1. Lists hide the complexity of memory management and provide simple operations for data manipulation (correct answer)
  2. Lists automatically encrypt stored data to protect sensitive information from unauthorized system access
  3. Lists convert all data types to a universal format for improved compatibility across platforms
  4. Lists compress data to reduce storage requirements and optimize overall system performance characteristics

Explanation: Lists are a data abstraction because they hide the complex details of how data is stored in memory and provide simple, high-level operations (like APPEND, INSERT, REMOVE) for manipulating collections of data. Choice B is incorrect because lists don't automatically encrypt data. Choice C is incorrect because lists don't convert data types. Choice D is incorrect because lists don't automatically compress data.

Question 2

A student grades list of integers starts as [90, 84, 76, 88, 95]. A teacher tries to add 10 points to the second grade, like a bonus for extra credit. The code mistakenly uses grades[2] = grades[2] + 10 while intending the second element. The list uses zero-based indexing. Only one element should be updated. Based on the scenario above, identify the error in the list operation and suggest a correction.

  1. Change to grades[1] = grades[1] + 10 (correct answer)
  2. Change to grades[2] = grades[2] + '10'
  3. Change to grades.remove(1)
  4. Change to grades.append(10)

Explanation: This question tests understanding of list operations in programming, specifically the relationship between element position and zero-based indexing. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the teacher wants to modify the second grade but uses grades[2], which actually accesses the third element due to zero-based indexing. Choice A is correct because grades[1] properly targets the second element (index 1 corresponds to the second position in zero-based indexing). Choice B is incorrect because it adds a string '10' instead of the integer 10, which would cause a type error when adding to an integer, showing confusion between data types. To help students: Create position-to-index conversion charts, practice identifying 'off-by-one' errors, and use consistent language distinguishing between 'position' (1st, 2nd) and 'index' (0, 1). Emphasize checking index values before operations.

Question 3

A shopping cart list of strings starts as ['milk','bread','eggs','apples','rice']. The shopper removes the item 'eggs' after deciding not to buy it, like taking it out of a real basket. The code uses cart.remove('eggs') to delete that exact element. The list keeps the remaining items in the same order. No other items are added or changed. In the context of the problem, how does the list change after removing the element?

  1. ['milk','bread','eggs','apples','rice']
  2. ['milk','bread','apples','rice'] (correct answer)
  3. ['eggs','milk','bread','apples','rice']
  4. ['milk','bread','apples','rice','eggs']

Explanation: This question tests understanding of list operations in programming, specifically the remove() method for deleting elements by value. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the shopping cart list ['milk','bread','eggs','apples','rice'] is modified through the remove() operation to delete 'eggs'. Choice B is correct because the remove() method deletes the first occurrence of the specified value ('eggs'), resulting in ['milk','bread','apples','rice'], with all remaining items maintaining their original order. Choice C is incorrect because it shows 'eggs' moved to the beginning rather than removed, which often occurs when students confuse remove() with other list operations. To help students: Emphasize that remove() deletes elements by value (not index), practice with visual representations of lists before and after operations, and use real-world analogies like removing items from a physical shopping cart. Have students trace through each operation step-by-step to predict outcomes.

Question 4

A song playlist list of strings starts as ['Blue','Gold','Neon','Pulse','River']. You remove one song by name, like deleting a track from a queue. The code runs playlist.remove('Neon') to delete that exact title. The remaining songs keep their current order. No other edits occur. In the context of the problem, how does the list change after removing the element?

  1. ['Blue','Gold','Pulse','River'] (correct answer)
  2. ['Neon','Blue','Gold','Pulse','River']
  3. ['Blue','Gold','Neon','Pulse','River']
  4. ['Blue','Gold','Pulse','River','Neon']

Explanation: This question tests understanding of list operations in programming, specifically the remove() method for deleting elements by value. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the playlist ['Blue','Gold','Neon','Pulse','River'] has the song 'Neon' removed using playlist.remove('Neon'). Choice A is correct because remove() deletes the specified element ('Neon') from its current position, resulting in ['Blue','Gold','Pulse','River'] with remaining elements maintaining their relative order. Choice C is incorrect because it shows 'Neon' still in the list but moved to a different position, which often occurs when students confuse remove() with reordering operations like sort() or insert(). To help students: Use visual demonstrations showing elements disappearing rather than moving, practice predicting list contents after remove() operations, and emphasize that remove() permanently deletes the first occurrence of a value. Create exercises comparing remove() with other list methods.

Question 5

A to-do list of strings starts as ['Pack','Print tickets','Charge phone','Lock door','Leave']. You try to mark the second task done with tasks[5] = 'DONE', but the list has only five items. In the context of the problem, identify the error in the list operation and suggest a correction.

  1. Use tasks[1] = 'DONE' (correct answer)
  2. Use tasks[5] = 'DONE' again
  3. Use tasks.append('DONE')
  4. Use tasks['1'] = 'DONE'

Explanation: This question tests understanding of list operations in programming, specifically index bounds and error correction. In programming, list indices must be within valid bounds (0 to length-1), and attempting to access index 5 in a 5-element list causes an error since valid indices are 0-4. In this scenario, the to-do list has 5 elements, so tasks[5] is out of bounds when trying to mark the second task as done. Choice A is correct because tasks[1] = 'DONE' properly accesses the second element (index 1) within the valid range. Choice B is incorrect because it suggests using the same invalid index again, showing a misunderstanding of the index bounds issue. To help students: Emphasize zero-based indexing and valid index ranges, practice identifying index errors, and use debugging exercises where students fix out-of-bounds errors. Teach students to check list length before accessing indices.

Question 6

A student grades list of integers starts as [88, 92, 76, 95, 84]. After a re-check, you update the third grade using grades[2] = 80. In the context of the problem, what is the output after executing the following list operation: grades[2]?

  1. 76
  2. 80 (correct answer)
  3. 92
  4. Index 5 is accessed

Explanation: This question tests understanding of list operations in programming, specifically updating elements using index notation. In programming, list elements can be modified by assigning new values to specific indices, where indexing starts at 0. In this scenario, the grades list [88, 92, 76, 95, 84] is modified by updating grades[2] = 80, which changes the third element (index 2) from 76 to 80. Choice B is correct because grades[2] now contains the value 80 after the assignment operation. Choice A is incorrect because it shows the original value 76, indicating a misunderstanding that assignment doesn't change the stored value. To help students: Practice with zero-based indexing, use visual representations showing index positions, and emphasize that assignment replaces the existing value completely. Have students verify their understanding by predicting values at different indices after updates.

Question 7

A sensor readings list of integers starts as [72, 74, 73, 75, 71]. You transfer data and then reset by setting readings = []. In the context of the problem, what is the output after executing the following list operation: len(readings)?

  1. 0 (correct answer)
  2. 1
  3. 5
  4. "0"

Explanation: This question tests understanding of list operations in programming, specifically the length of an empty list. In programming, lists can be emptied by assigning an empty list [], and the len() function returns the number of elements currently in the list. In this scenario, the sensor readings list is reset to an empty list using readings = [], which removes all elements. Choice A is correct because len([]) returns 0, as an empty list contains zero elements regardless of its previous contents. Choice C is incorrect because it represents the original list length, indicating a misunderstanding that assignment doesn't affect the list's current state. To help students: Emphasize that assignment with = completely replaces the list contents, practice with the len() function on lists of various sizes including empty lists, and distinguish between modifying a list and replacing it entirely. Use debugging exercises where students predict len() outputs for different list states.

Question 8

A song playlist list of strings starts as ['Intro','Skyline','Drive','Echoes','Finale']. You add a new song at the end, like adding a track to the end of a mixtape. The goal is to use append so the new title becomes the last element. No other songs move or get removed. The list remains in the same order otherwise. Based on the scenario above, which line of code correctly adds an item to the list?

  1. playlist.remove('New Song')
  2. playlist.append('New Song') (correct answer)
  3. playlist['New Song'].append()
  4. playlist[0] = 'New Song'

Explanation: This question tests understanding of list operations in programming, specifically the append() method for adding elements to the end of a list. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the playlist needs a new song added at the end using the append() method. Choice B is correct because playlist.append('New Song') adds the new element to the end of the list, making it the sixth and final element. Choice D is incorrect because playlist[0] = 'New Song' would replace the first song rather than add a new one, which often occurs when students confuse assignment with addition. To help students: Demonstrate append() with physical objects being added to the end of a line, contrast append() with insert() and assignment operations, and use visual animations showing lists growing. Practice identifying when to modify existing elements versus adding new ones.

Question 9

A to-do list of strings starts as ['pay bills','call mom','exercise','read','clean room']. You decide to prioritize by sorting alphabetically, like organizing sticky notes by title. The code runs tasks.sort() and keeps all items. No tasks are added or removed. The sorted list becomes ['call mom','clean room','exercise','pay bills','read']. In the context of the problem, what is the index of the element in the list after sorting?

  1. Index of 'pay bills' is 2
  2. Index of 'pay bills' is 0
  3. Index of 'pay bills' is 3 (correct answer)
  4. Index of 'pay bills' is 4

Explanation: This question tests understanding of list operations in programming, specifically the sort() method and finding indices after sorting. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the to-do list is sorted alphabetically, changing from ['pay bills','call mom','exercise','read','clean room'] to ['call mom','clean room','exercise','pay bills','read']. Choice C is correct because after sorting, 'pay bills' moves to index 3 (fourth position) in the alphabetically ordered list. Choice A is incorrect because it suggests index 2, which often occurs when students count the position of 'pay bills' in the original list or miscount in the sorted list. To help students: Practice sorting lists manually first, then trace where each element moves, create before-and-after index maps, and emphasize that sort() rearranges all elements. Use exercises where students predict new positions after sorting.

Question 10

A sensor readings list of integers starts as [19, 21, 20, 22, 18]. You receive a new reading and add it using readings.append(23) to keep the sequence. Based on the scenario above, how many elements are in the list after the given operations?

  1. 5 elements
  2. 6 elements (correct answer)
  3. 7 elements
  4. Index 6 is accessed

Explanation: This question tests understanding of list operations in programming, specifically how append() affects list size. In programming, the append() method adds one element to the end of a list, increasing its length by exactly one. In this scenario, the sensor readings list [19, 21, 20, 22, 18] starts with 5 elements, and append(23) adds one more element. Choice B is correct because 5 + 1 = 6 elements after the append operation, with the new reading 23 added at the end. Choice A is incorrect because it shows the original count, indicating the student didn't account for the append operation's effect on list size. To help students: Practice counting elements before and after append operations, use visual representations showing list growth, and emphasize that each append() increases length by exactly one. Have students verify counts by listing all elements after operations.

Question 11

A sensor readings list of integers starts as [21, 22, 20, 23, 22]. A technician checks one specific reading using an index, like looking up a time stamp in a log. The code prints readings[3] using zero-based index. No readings are modified or removed. The list stays in the same order. Based on the scenario above, what is the output after executing the following list operation?

  1. 20
  2. 22
  3. 23 (correct answer)
  4. 21

Explanation: This question tests understanding of list operations in programming, specifically accessing elements by index. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the sensor readings list [21, 22, 20, 23, 22] is accessed at index 3 using readings[3]. Choice C is correct because in zero-based indexing, index 3 refers to the fourth element, which is 23 (indices 0→21, 1→22, 2→20, 3→23, 4→22). Choice D is incorrect because it shows the value at index 0 (21), which often occurs when students think index 3 means 'third from the end' or miscount positions. To help students: Use visual number lines showing index positions below list elements, practice with finger counting starting from 0, and create index-to-value mapping exercises. Emphasize that the first element is always at index 0, not 1.

Question 12

A sensor readings list of integers starts as [18, 19, 21, 20, 19]. After transferring data, the system resets the list, like clearing a clipboard after pasting. The code runs readings.clear() to remove all elements. No new readings are added afterward. The list becomes empty. Based on the scenario above, how many elements are in the list after the given operations?

  1. 1
  2. 5
  3. 0 (correct answer)
  4. 4

Explanation: This question tests understanding of list operations in programming, specifically the clear() method that removes all elements. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the sensor readings list with 5 elements is completely emptied using the clear() method, like erasing all data from a clipboard. Choice C is correct because clear() removes all elements from the list, leaving it empty with 0 elements, regardless of how many items were originally present. Choice B is incorrect because it suggests the list still has 5 elements, which often occurs when students think clear() only resets values to zero rather than removing all elements entirely. To help students: Demonstrate clear() with physical containers being emptied completely, contrast with remove() which deletes single items, and show that an empty list has length 0. Practice checking list lengths after various operations.

Question 13

A shopping cart list of strings starts as ['soap','shampoo','toothpaste','towel','lotion']. The shopper wants to remove the last item by index, like putting the last-picked item back on the shelf. The code tries cart.remove(cart[5]) to remove that last element. The list has only five items with zero-based indices 0 to 4. Nothing else changes. Based on the scenario above, identify the error in the list operation and suggest a correction.

  1. Use cart.remove(cart[4]) instead (correct answer)
  2. Use cart.remove(cart[5]) instead
  3. Use cart.append(cart[5]) instead
  4. Use cart[5] = 'lotion' instead

Explanation: This question tests understanding of list operations in programming, specifically index bounds and the remove() method. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the shopping cart has 5 items (indices 0-4), but the code incorrectly tries cart.remove(cart[5]), which causes an index out of bounds error. Choice A is correct because cart.remove(cart[4]) properly accesses the last element (at index 4) in a 5-element list with zero-based indexing. Choice B is incorrect because it still uses index 5, which doesn't exist, showing students haven't understood the core issue of index bounds. To help students: Create index charts showing valid ranges for lists of different sizes, practice identifying the last valid index (always length - 1), and use error messages as learning opportunities. Emphasize checking list bounds before accessing elements.

Question 14

A to-do list of strings starts as ['email boss','wash dishes','study','buy groceries','walk dog']. You mark one task complete by removing it, like crossing a note off a fridge list. The code runs tasks.remove('wash dishes') to delete that task. The remaining tasks stay in their original order. No new tasks are added. Based on the scenario above, how many elements are in the list after the given operations?

  1. 3
  2. 6
  3. 4 (correct answer)
  4. 5

Explanation: This question tests understanding of list operations in programming, specifically counting elements after a remove() operation. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the to-do list starts with 5 tasks and one task ('wash dishes') is removed using the remove() method. Choice C is correct because after removing one element from a 5-element list, 4 elements remain (5 - 1 = 4), which is a fundamental counting operation. Choice D is incorrect because it suggests no change in the list size, which often occurs when students think remove() only marks items rather than actually deleting them. To help students: Use visual diagrams showing lists shrinking when elements are removed, practice counting operations with physical objects, and emphasize that remove() permanently deletes elements. Encourage students to verify list lengths before and after operations using len() function.

Question 15

A student grades list of integers starts as [78, 92, 85, 69, 88]. After a re-check, the third grade increases by 5 points, like correcting a score on a paper. The code updates grades[2] = grades[2] + 5 using zero-based index. All other grades stay the same. The list order does not change. In the context of the problem, what is the output after executing the following list operation?

  1. [78, 92, 90, 69, 88] (correct answer)
  2. [78, 92, 85, 74, 88]
  3. [78, 92, 85, 69, 93]
  4. [78, 97, 85, 69, 88]

Explanation: This question tests understanding of list operations in programming, specifically modifying elements by index and performing arithmetic operations. In programming, lists are used to store collections of items. Common operations include adding, removing, and accessing elements using indices. In this scenario, the grades list [78, 92, 85, 69, 88] has its third element (index 2, value 85) increased by 5 points using grades[2] = grades[2] + 5. Choice A is correct because the operation changes only the element at index 2 from 85 to 90 (85 + 5 = 90), resulting in [78, 92, 90, 69, 88]. Choice D is incorrect because it shows the second element (index 1) changed instead, which often occurs when students confuse one-based counting with zero-based indexing. To help students: Create index reference cards showing positions 0-4 for a 5-element list, practice tracing operations with index arrows, and emphasize that list indices start at 0. Use debugging exercises where students predict which element will change.

Question 16

A shopping cart list of strings starts as ['soap','shampoo','toothpaste','lotion','razor']. You add 'deodorant' at checkout using cart.append('deodorant') to include it in the order. Based on the scenario above, what is the output after executing the following list operation: cart[-1]?

  1. 'razor'
  2. 'soap'
  3. 'deodorant' (correct answer)
  4. Index 6 is accessed

Explanation: This question tests understanding of list operations in programming, specifically negative indexing and the append() method. In programming, append() adds an element to the end of a list, and negative indices count from the end, with -1 referring to the last element. In this scenario, the shopping cart ['soap','shampoo','toothpaste','lotion','razor'] gets 'deodorant' appended, making it the new last element. Choice C is correct because cart[-1] returns 'deodorant', which is the most recently added element at the end of the list. Choice A is incorrect because 'razor' was the last element before the append operation, showing a misunderstanding of how append() affects list structure. To help students: Practice with negative indexing, emphasize that -1 always refers to the current last element, and use visual diagrams showing how append() extends the list. Have students trace both positive and negative indices after list modifications.

Question 17

A student grades list of integers starts as [70, 85, 90, 60, 95]. You remove the lowest grade using grades.remove(60) to drop one quiz score. Based on the scenario above, how many elements are in the list after the given operations?

  1. 3 elements
  2. 4 elements (correct answer)
  3. 5 elements
  4. 6 elements

Explanation: This question tests understanding of list operations in programming, specifically removing elements and counting the remaining items. In programming, remove() deletes the first occurrence of a specified value, reducing the list length by one. In this scenario, the grades list [70, 85, 90, 60, 95] has 5 elements initially, and remove(60) deletes the lowest grade, leaving 4 elements. Choice B is correct because removing one element from a 5-element list results in exactly 4 remaining elements: [70, 85, 90, 95]. Choice C is incorrect because it represents the original count, suggesting the student didn't recognize that remove() decreases list size. To help students: Practice predicting list lengths after various operations, use visual demonstrations of element removal, and emphasize that each successful remove() call decreases length by one. Have students verify by counting remaining elements.

Question 18

A to-do list of strings starts as ['Email boss','Buy groceries','Study','Workout','Call mom']. You finish 'Workout' and remove it so only remaining tasks show. Based on the scenario above, how many elements are in the list after the given operations?

  1. 3 elements
  2. 4 elements (correct answer)
  3. 5 elements
  4. Index 5 is accessed

Explanation: This question tests understanding of list operations in programming, specifically counting elements after removal. In programming, lists dynamically adjust their size when elements are added or removed, and the len() function returns the current number of elements. In this scenario, the to-do list ['Email boss','Buy groceries','Study','Workout','Call mom'] has 5 elements initially, and removing 'Workout' reduces it to 4 elements. Choice B is correct because after removing one element from a 5-element list, exactly 4 elements remain: ['Email boss','Buy groceries','Study','Call mom']. Choice C is incorrect because it represents the original count, suggesting the student didn't account for the removal operation's effect on list size. To help students: Practice counting elements before and after operations, use visual diagrams showing list changes, and emphasize that remove() decreases the list length by one. Encourage students to verify their answers by mentally listing all remaining elements.

Question 19

A shopping cart list of strings starts as ['milk','eggs','bread','apples','rice']. A user removes 'bread' to reflect an out-of-stock item, and the cart updates immediately. In the context of the problem, how does the list change after removing the element?

  1. ['milk','eggs','apples','rice'] (correct answer)
  2. ['bread','milk','eggs','apples','rice']
  3. ['milk','eggs','bread','apples','rice','bread']
  4. ['milk','eggs','apples','bread','rice']

Explanation: This question tests understanding of list operations in programming, specifically removing elements from a list. In programming, lists are used to store collections of items, and the remove() operation deletes the first occurrence of a specified element, shifting remaining elements to fill the gap. In this scenario, the shopping cart list ['milk','eggs','bread','apples','rice'] is modified by removing 'bread', which is at index 2. Choice A is correct because removing 'bread' results in ['milk','eggs','apples','rice'], with the elements after 'bread' shifting left to maintain list continuity. Choice C is incorrect because it shows 'bread' appearing twice in the result, which represents a conceptual misunderstanding of how remove() works - it doesn't duplicate elements. To help students: Use visual representations showing how elements shift when items are removed, practice with physical objects to demonstrate list operations, and emphasize that remove() deletes only the first occurrence of an element. Have students trace through list operations step-by-step to predict outcomes.

Question 20

A playlist list of strings starts as ['Intro','Skyline','Drift','Neon','Finale']. You remove 'Neon' because it is unavailable offline before your run. Based on the scenario above, how does the list change after removing the element?

  1. ['Intro','Skyline','Drift','Finale'] (correct answer)
  2. ['Neon','Intro','Skyline','Drift','Finale']
  3. ['Intro','Skyline','Drift','Neon','Finale','Neon']
  4. ['Intro','Skyline','Neon','Drift','Finale']

Explanation: This question tests understanding of list operations in programming, specifically removing elements and how it affects list structure. In programming, the remove() method deletes the first occurrence of a specified value, and all subsequent elements shift left to fill the gap. In this scenario, the playlist ['Intro','Skyline','Drift','Neon','Finale'] has 'Neon' at index 3, which is removed. Choice A is correct because removing 'Neon' results in ['Intro','Skyline','Drift','Finale'], with 'Finale' shifting from index 4 to index 3. Choice D is incorrect because it shows 'Neon' still present but in a different position, reflecting a misunderstanding that remove() might reorder rather than delete elements. To help students: Use animations showing how list elements shift after removal, practice predicting list contents after various operations, and emphasize that remove() completely deletes the element. Have students trace index changes when elements are removed.