Courseiva
Strings →hardMultiple Select

PCAP Strings Practice Question

Which THREE of the following expressions return the string "Python"? (Choose three.)

⚠ Common exam trap

A common trap is the misconception that a slice with a step other than 1 (e.g., '::2') returns the full string, or that negative step or omitted stop index produces the same result as a full slice.

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

✓

"Python"[:]

Slicing the entire string with '[:]' returns a copy of the full string, which is 'Python'. This is a common idiom for copying a sequence in Python.

Answer analysis

Option-by-option breakdown

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

  • ✗

    "Python"[::2]

    Why it's wrong here

    The slice `"Python"[::2]` uses a default start of 0 and a default stop at the string's length, but a step of 2 selects only every second character. Starting at index 0, it takes characters at indices 0, 2, and 4, which are 'P', 't', and 'o', producing the substring `'Pto'`. Because the step is greater than 1, this slice deliberately skips the characters at odd indices, so it cannot return the entire original string.

  • ✓

    "Python"[:]

    Why this is correct

    The expression `"Python"[:]` is a full slice: both the start and stop indices are omitted, and the step defaults to 1. With these defaults, Python interprets the slice as starting at index 0 and stopping at the length of the sequence, thereby including every character in order. This idiom is commonly used to create a copy of a sequence; here it returns a new string object containing exactly the same characters as the original: `'Python'`.

  • ✓

    "Python"[0:6:1]

    Why this is correct

    The slice `"Python"[0:6:1]` explicitly provides a start index of 0, a stop index of 6, and a step of 1. Since the stop index is exclusive, it includes indices 0 through 5, which are all six characters of the string, and a step of 1 means no characters are skipped. Walking through the indices in order yields `'P'`, `'y'`, `'t'`, `'h'`, `'o'`, `'n'`, so the result is the complete string `'Python'`.

  • ✓

    "Python"[0:6]

    Why this is correct

    In `"Python"[0:6]`, the start index is 0 and the stop index is 6, with the step defaulting to 1. The stop index is exclusive, so the slice includes characters at positions 0, 1, 2, 3, 4, and 5—exactly the six characters that make up the string. Thus this slice selects the entire string and returns `'Python'`, matching the original content character for character.

  • ✗

    "Python"[:-1]

    Why it's wrong here

    The slice `"Python"[:-1]` uses a negative stop index, which counts from the end of the string; here -1 refers to the last character 'n'. Since the stop index is exclusive, that final character is omitted from the result, leaving only the substring `'Pytho'` (indices 0 through 4). Therefore this slice returns everything except the last character, so it is not the full string `'Python'`.

About these practice questions

Courseiva writes every PCAP question from scratch — 421 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 PCAP 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 PCAP exam.