PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions
A developer needs to determine the number of elements in a tuple named 't'. Which code snippet will correctly return the length?
⚠ Common exam trap
The PCEP exam often tests the immutability of tuples by presenting list-specific methods (like `append`, `pop`, or item assignment) as distractors, knowing that candidates may confuse tuples with lists.
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
✓
len(t)
The correct way to determine the number of elements in a tuple in Python is to use the built-in `len()` function, which returns the length (number of items) of any sequence or collection, including tuples. Option C is correct because `len(t)` directly gives the count of elements in tuple `t`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
t.append(5)
Why it's wrong here
append() is a list method, not available for tuples.
- ✗
t[0] = 5
Why it's wrong here
Tuples are immutable; item assignment causes TypeError.
- ✓
len(t)
Why this is correct
The built-in len() function returns the number of elements in a tuple.
- ✗
t.pop()
Why it's wrong here
pop() is a list method; tuples do not have this method.
Go deeper
Related to this question
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 →
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.