Courseiva
Computer Programming and Python FundamentalshardMultiple ChoiceObjective-mapped

PCEP Computer Programming and Python Fundamentals Practice Question

Exhibit

Refer to the exhibit.

```
my_list = [1, 2, 3, 4, 5]
my_list[1:3] = [10, 20]
print(my_list)
```

What is the output of the code in the exhibit?

⚠ Common exam trap

Python Institute often tests the distinction between `extend()` and `append()`, and the precise behavior of step slicing, leading candidates to mistakenly think `extend()` inserts elements at a specific position or that `[::2]` removes elements rather than selecting every second one.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

[1, 10, 20, 4, 5]

The code uses list slice assignment to replace the elements at indices 1 and 2 (the second and third elements) with the list [10, 20]. Starting from [1, 2, 3, 4, 5], after the assignment lst[1:3] = [10, 20], the list becomes [1, 10, 20, 4, 5]. This matches option B.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • [1, 2, 10, 20, 5]

    Why it's wrong here

    Indices incorrect: slice 1:3 replaces elements at positions 1 and 2.

  • [1, 10, 20, 4, 5]

    Why this is correct

    Correct replacement.

  • [1, 2, 3, 10, 20, 4, 5]

    Why it's wrong here

    That would be insertion, not replacement.

  • [1, 10, 20, 3, 4, 5]

    Why it's wrong here

    Indices incorrect.

About these practice questions

Courseiva writes every PCEP question from scratch — 498 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.