jenniferanderson2002
jenniferanderson2002 2d ago • 0 views

Extending Python Lists: Examples with Code for AP CSP

Hey AP CSP students! 👋 Let's dive into extending Python lists. It's super useful and not as hard as it sounds. Here's a quick guide and a practice quiz to help you ace it! 💯
💻 Computer Science & Technology
🪄

🚀 Can't Find Your Exact Topic?

Let our AI Worksheet Generator create custom study notes, online quizzes, and printable PDFs in seconds. 100% Free!

✨ Generate Custom Content

1 Answers

✅ Best Answer
User Avatar
tracy.buckley Jan 1, 2026

📚 Quick Study Guide

  • ➕ List extension involves adding elements to an existing list.
  • 🐍 Python provides several ways to extend lists, including: `append()`, `extend()`, `insert()`, and list concatenation (`+`).
  • ➡️ `append(element)`: Adds a single element to the end of the list.
  • 🔗 `extend(iterable)`: Adds elements from an iterable (like another list, tuple, or string) to the end of the list.
  • 📍 `insert(index, element)`: Inserts an element at a specific index in the list.
  • 💡 List Concatenation (`+`): Creates a new list by combining two existing lists.
  • ⚠️ Be mindful of the differences: `append` adds the element as-is, while `extend` unpacks the iterable and adds each element individually.

🧪 Practice Quiz

  1. Which method adds a single element to the end of a Python list?
    1. append()
    2. extend()
    3. insert()
    4. concat()
  2. Which method adds multiple elements from an iterable to the end of a Python list?
    1. append()
    2. extend()
    3. insert()
    4. add()
  3. What is the output of the following code?
    list1 = [1, 2, 3]
    list1.append([4, 5])
    print(list1)
    1. [1, 2, 3, 4, 5]
    2. [1, 2, 3, [4, 5]]
    3. Error
    4. [4, 5]
  4. What is the output of the following code?
    list1 = [1, 2, 3]
    list1.extend([4, 5])
    print(list1)
    1. [1, 2, 3, [4, 5]]
    2. [1, 2, 3, 4, 5]
    3. Error
    4. [4, 5]
  5. Which method inserts an element at a specific position in a Python list?
    1. append()
    2. extend()
    3. insert()
    4. add()
  6. What is the output of the following code?
    list1 = [1, 2, 3]
    list1.insert(1, 4)
    print(list1)
    1. [1, 2, 3, 4]
    2. [1, 4, 2, 3]
    3. [4, 1, 2, 3]
    4. Error
  7. Which operator can be used to concatenate two lists in Python?
    1. *
    2. +
    3. -
    4. /
Click to see Answers
  1. A
  2. B
  3. B
  4. B
  5. C
  6. B
  7. B

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀