Courseiva

PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions

Which TWO of the following are valid methods that can be called on a tuple object? (Choose two.)

⚠ Common exam trap

The PCEP exam often tests the distinction between mutable and immutable sequence types, trapping candidates who assume that because lists have methods like `.pop()`, `.append()`, and `.sort()`, tuples must have them too, when in fact tuples only support non-mutating methods like `.index()` and `.count()`.

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

✓

.index()

The `.index()` method is a built-in tuple method that returns the index of the first occurrence of a specified value. Tuples are immutable sequences, so they support only non-mutating methods like `.index()` and `.count()`, which do not modify the tuple.

Answer analysis

Option-by-option breakdown

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

  • ✗

    .pop()

    Why it's wrong here

    Tuples are immutable, so .pop() cannot exist: it removes and returns an item, mutating the sequence. It tempts because .pop() is a familiar list method, and it would be valid on a list or other mutable sequence, but tuple objects expose only non-mutating methods such as .count() and .index().

  • ✓

    .index()

    Why this is correct

    .index() searches a tuple for a specified value and returns the zero-based position of its first occurrence, raising ValueError when absent. Tuples support this read-only lookup because it mutates nothing, satisfying the immutability constraint while providing the membership-position query the question requires.

  • ✗

    .append()

    Why it's wrong here

    Tuples are immutable, so .append() cannot exist: it adds an element in place, mutating the sequence. It tempts because .append() is a common list method, and it would be valid on a list, but tuple objects expose only non-mutating methods such as .count() and .index().

  • ✗

    .sort()

    Why it's wrong here

    Tuples are immutable, so .sort() cannot exist: it reorders elements in place, mutating the sequence. It tempts because .sort() is a familiar list method, and it would be valid on a list, but tuple objects expose only non-mutating methods such as .count() and .index().

  • ✓

    .count()

    Why this is correct

    Tuples implement the sequence protocol, so `.count()` is available: it returns the number of occurrences of a given value within the tuple, satisfying the stem's requirement for a valid tuple method. This read-only query suits tuples' immutability, since counting requires no modification of the underlying object.

About these practice questions

This PCEP question is part of Courseiva's 482-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.