Learn Without Walls
← Back to Module 6

Module 6 Quiz: Lists

Test your understanding with 12 questions. You need 70% (9 out of 12) to pass. Good luck!

Question 1

What is the correct way to create an empty list in Python?

  • list = ()
  • my_list = []
  • my_list = {}
  • my_list = empty()

Question 2

Given fruits = ["apple", "banana", "cherry", "date"], what does fruits[2] return?

  • "banana"
  • "apple"
  • "cherry"
  • "date"

Question 3

Given nums = [10, 20, 30, 40, 50], what does nums[-2] return?

  • 20
  • 50
  • 30
  • 40

Question 4

What is the difference between append() and extend()?

  • They do the same thing
  • append() adds a single item; extend() adds each item from an iterable individually
  • append() adds to the beginning; extend() adds to the end
  • append() returns a new list; extend() modifies in place

Question 5

What does pop() do when called without arguments?

  • Removes the first element
  • Removes all elements
  • Removes and returns the last element
  • Returns the last element without removing it

Question 6

Given data = [5, 3, 8, 1, 9], what does data.sort() return?

  • None (it modifies the list in place)
  • [1, 3, 5, 8, 9]
  • [9, 8, 5, 3, 1]
  • A new sorted list

Question 7

Given nums = [1, 2, 3, 4, 5, 6, 7, 8], what does nums[2:6] return?

  • [2, 3, 4, 5, 6]
  • [3, 4, 5, 6]
  • [3, 4, 5]
  • [2, 3, 4, 5]

Question 8

What does my_list[::-1] do?

  • Returns the first element
  • Removes the last element
  • Sorts the list in reverse
  • Returns a reversed copy of the list

Question 9

What happens when you write copy = original with lists?

  • A new independent copy is created
  • An error is raised
  • Both variables point to the same list in memory
  • The original list is deleted

Question 10

What does this list comprehension produce? [x * 2 for x in range(5)]

  • [0, 2, 4, 6, 8]
  • [2, 4, 6, 8, 10]
  • [1, 2, 3, 4, 5]
  • [0, 1, 2, 3, 4]

Question 11

What does [x for x in range(10) if x % 2 == 0] produce?

  • [1, 3, 5, 7, 9]
  • [0, 2, 4, 6, 8]
  • [2, 4, 6, 8, 10]
  • [0, 1, 2, 3, 4]

Question 12

Which of the following is the best use case for a list comprehension?

  • Complex logic with multiple if/elif/else branches and side effects
  • Printing each item in a list
  • Reading and writing files for each item
  • Creating a new list by transforming each element of an existing list

Quiz Results

Back to Module 6