Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

Which two of the following are true about Python lists? (Choose two.)

⚠ Common exam trap

The traps here include confusing list mutability with immutability, assuming indexing starts from 1, and mistakenly believing lists can be used as dictionary keys.

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

✓

Lists can contain elements of different data types.

Option A is correct because Python lists are heterogeneous ordered collections, so a single list may hold elements of different data types (e.g., [1, 'two', 3.0, True]) without any type restriction. Option E is correct because the built-in len() function returns the number of elements in a list, such as len([10, 20, 30]) returning 3. Option B is incorrect because lists are mutable and therefore unhashable, so they cannot be used as dictionary keys (a TypeError is raised). Option C is incorrect because Python uses zero-based indexing, so the first element is at index 0, not 1. Option D is incorrect because lists are mutable: elements can be added, removed, or reassigned in place via methods like append(), remove(), or item assignment.

Answer analysis

Option-by-option breakdown

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

  • ✓

    Lists can contain elements of different data types.

    Why this is correct

    Python lists are heterogeneous: a single list may hold integers, strings, floats and even nested lists together, because elements are references without a declared type. This satisfies the statement that lists accept elements of differing data types.

  • ✗

    Lists can be used as dictionary keys.

    Why it's wrong here

    Dictionary keys must be hashable, and lists define no __hash__ because they are mutable; using one raises TypeError. Tuples, strings and frozensets are hashable and serve as keys. Lists are correct as dictionary values, which is the confusion this option exploits.

  • ✗

    Lists are indexed starting from 1.

    Why it's wrong here

    Python list indices begin at 0, so the first element sits at position zero; negative indices count backwards from the end. Lists are mutable sequences, not 1-based. A 1-based scheme applies to other languages, and to Python's own enumerate start parameter, not to list indexing itself.

  • ✗

    Lists are immutable.

    Why it's wrong here

    Lists are mutable: append, extend, insert, remove and slice assignment all modify the object in place without creating a new one. Immutability describes tuples, strings and frozensets. The stem asks what is true of lists, and in-place mutation is a defining characteristic of the type.

  • ✓

    The len() function returns the number of elements.

    Why this is correct

    The built-in len() function returns an integer count of the elements held in a list, so len([1, 2, 3]) yields 3. This directly satisfies the statement about list length, making it one of the two true options.

About these practice questions

Courseiva writes every PCEP question from scratch — 482 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.