Courseiva
Computer Programming and Python FundamentalseasyMultiple ChoiceObjective-mapped

PCEP Computer Programming and Python Fundamentals Practice Question

A programmer wants to iterate over a list of strings and print each string in uppercase. Which of the following code snippets will accomplish this?

⚠ Common exam trap

The trap here is that candidates often forget to include parentheses when calling a method (e.g., `item.upper` vs `item.upper()`), or they mistakenly think `upper()` modifies the string in place, leading them to print the original variable instead of the returned value.

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

for item in my_list: print(item.upper())

It correctly calls the `upper()` method on each string `item` in the list `my_list` and prints the result. The `upper()` method returns a new string with all characters converted to uppercase, and the `print()` function outputs that value to the console.

Answer analysis

Option-by-option breakdown

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

  • for item in my_list: print(item.upper)

    Why it's wrong here

    Prints method object, not result.

  • for item in my_list: item.upper() print(item)

    Why it's wrong here

    Missing colon and incorrect syntax.

  • for i in my_list: print(my_list[i].upper())

    Why it's wrong here

    i is an element, not an index.

  • for item in my_list: print(item.upper())

    Why this is correct

    Correct iteration and method call.

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.