Skip to content
QuiznExam

Lists, Tuples & Sets in Python

Test your knowledge of Python lists, tuples, and sets, including their properties, indexing, mutability, common methods, operations, and practical usage.

15
Questions
12 min
Time limit
Medium
Difficulty

No sign-up needed · Last updated:

Save your score

At least 8 characters.

Forgot password?

Related quizzes

All 15 questions and answers Spoilers: this shows the questions and answers. Try the quiz first! Open
  1. 1. Which Python data structure is ordered, mutable, and allows duplicate elements?

    • A. List
    • B. Tuple
    • C. Set
    • D. Dictionary
    Show answer

    A. List

    Lists are ordered and mutable collections that can contain duplicate elements.

  2. 2. Which syntax correctly creates a Python list?

    • A. (1, 2, 3)
    • B. {1, 2, 3}
    • C. [1, 2, 3]
    • D. <1, 2, 3>
    Show answer

    C. [1, 2, 3]

    Square brackets are used to create list literals in Python.

  3. 3. Which Python collection is immutable?

    • A. List
    • B. Tuple
    • C. Set
    • D. Bytearray
    Show answer

    B. Tuple

    Tuples are immutable, meaning their elements cannot be changed after the tuple is created.

  4. 4. Which syntax correctly creates a tuple containing three integers?

    • A. [1, 2, 3]
    • B. {1, 2, 3}
    • C. (1, 2, 3)
    • D. <1, 2, 3>
    Show answer

    C. (1, 2, 3)

    Parentheses are commonly used for tuple literals, although commas are what define tuple packing.

  5. 5. Which Python collection automatically eliminates duplicate elements?

    • A. List
    • B. Tuple
    • C. Set
    • D. String
    Show answer

    C. Set

    A set contains unique elements, so duplicate values are represented only once.

  6. 6. Which syntax creates an empty set in Python?

    • A. {}
    • B. []
    • C. set()
    • D. ()
    Show answer

    C. set()

    set() creates an empty set. {} creates an empty dictionary.

  7. 7. Which list method adds an element to the end of a list?

    • A. add()
    • B. append()
    • C. insertEnd()
    • D. push()
    Show answer

    B. append()

    The append() method adds one element to the end of a list.

  8. 8. Which list method removes and returns an element from a specified position, defaulting to the last element?

    • A. remove()
    • B. delete()
    • C. pop()
    • D. discard()
    Show answer

    C. pop()

    The pop() method removes and returns an item by index, defaulting to the last item when no index is supplied.

  9. 9. Which operation can be used to access the first element of a list named numbers?

    • A. numbers[0]
    • B. numbers[1]
    • C. numbers.first()
    • D. numbers(0)
    Show answer

    A. numbers[0]

    Python sequences use zero-based indexing, so index 0 refers to the first element.

  10. 10. Which set method adds a single element to a set?

    • A. append()
    • B. insert()
    • C. add()
    • D. push()
    Show answer

    C. add()

    The add() method inserts a single element into a set.

  11. 11. Which set operation returns elements that are present in both sets?

    • A. Union
    • B. Difference
    • C. Intersection
    • D. Concatenation
    Show answer

    C. Intersection

    Set intersection returns elements common to both sets and can be performed with & or intersection().

  12. 12. Which operator is used to calculate the union of two sets?

    • A. &
    • B. |
    • C. ^
    • D. -
    Show answer

    B. |

    The | operator performs set union, combining the unique elements from both sets.

  13. 13. Which statement about tuples is correct?

    • A. Tuples can be modified after creation
    • B. Tuples cannot contain duplicate values
    • C. Tuples are immutable sequences
    • D. Tuples only contain numbers
    Show answer

    C. Tuples are immutable sequences

    Tuples are ordered, immutable sequences and can contain duplicate values and different data types.

  14. 14. What happens when you try to add a duplicate value to a set?

    • A. A second copy is always added
    • B. The set keeps only one occurrence
    • C. The set is converted to a list
    • D. Python raises a duplicate-value error
    Show answer

    B. The set keeps only one occurrence

    Sets contain unique elements, so adding an element that is already present does not create a duplicate.

  15. 15. Which statement correctly describes the main difference between a list and a tuple?

    • A. Lists are immutable while tuples are mutable
    • B. Lists use keys while tuples use values
    • C. Lists are mutable while tuples are immutable
    • D. Lists cannot contain duplicates while tuples can
    Show answer

    C. Lists are mutable while tuples are immutable

    The key distinction is that list contents can be changed after creation, while tuple contents cannot be changed.