Courseiva
Computer Programming and Python FundamentalsmediumMultiple ChoiceObjective-mapped

PCEP Computer Programming and Python Fundamentals Practice Question

A junior developer is writing a script to process a list of user IDs: ids = [101, 102, 103, 104]. The goal is to create a new list where each ID is increased by 10, without modifying the original list. The developer writes: new_ids = ids.append(10). However, the output shows None. The developer needs to correctly create the new list. Which code should the developer use to achieve this?

⚠ Common exam trap

Python Institute often tests the distinction between methods that modify a list in place and return `None` (like `append()`, `sort()`) versus those that return a new object (like list comprehensions or `sorted()`), leading candidates to mistakenly assign the result of `append()` to a variable.

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

new_ids = [id + 10 for id in ids]

It uses a list comprehension to create a new list by adding 10 to each element of the original list `ids`, leaving the original list unchanged. The `append()` method modifies the list in place and returns `None`, which is why the developer got `None`.

Answer analysis

Option-by-option breakdown

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

  • new_ids = [id + 10 for id in ids]

    Why this is correct

    List comprehension creates a new list with increments, original unchanged.

  • for i in range(len(ids)): ids[i] += 10; new_ids = ids

    Why it's wrong here

    Modifies the original list, so original ids are changed.

  • new_ids = ids + 10

    Why it's wrong here

    Cannot concatenate list and int; TypeError.

  • new_ids = map(lambda x: x+10, ids)

    Why it's wrong here

    map returns an iterator, not a list. Needs list() conversion.

About these practice questions

This PCEP question is part of Courseiva's 498-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.