Grade 6 · lesson 2 of 4

Slice a Stated Segment of Text

Include the start index and stop before the stated stop index.

About 18 minutes, plus any extended practice

Download the grade pack

Supplied materials

  • Paper and pencil; answers may also be spoken or typed.
  • All cases, labels, numbers and rules are supplied on this page. No real account, private information or purchase is needed.

Learn the idea

A Python slice start:stop includes the start position and excludes the stop position. The slice is a new sequence containing the selected segment. These cases use positive positions only. Counting indices and marking the excluded endpoint prevents a common off-by-one error.

Include the start index and stop before the stated stop index. Do not include the stop-position character.

Use this supplied case: Paper Python 3 expression: "garden"[0:3]. What value results? The task is to connect the given information to the computing idea. Write a short evidence trail so another learner can reproduce your choice. The simplified case describes the stated model, not every real system.

  1. Represent the supplied worked case with a labeled drawing, table or short trace.
  2. Include the start index and stop before the stated stop index.
  3. Explain why the worked answer fits and why one alternative does not.
  4. Try the new check and practice cases; revisit the stated rule if your evidence does not match.
Worked example

See the method in action

For "garden", positions are 0:g, 1:a, 2:r, 3:d, 4:e, 5:n. Slice [0:3] includes 0,1,2 and gives "gar". For the different text "basket", positions 2,3,4 contain s,k,e, so [2:5] gives "ske" and excludes the t at position 5. These slices use a start-inclusive, stop-exclusive rule. Sorting characters or including the stop position would apply a different operation.

Your turn

Check your reasoning

Your answer is temporary and is not saved to an account. Download your current answer before leaving or reloading. Written work on paper or in another app stays in your own file.

Helpful tips
  • Include the start index and stop before the stated stop index.
  • Do not include the stop-position character.
Paper Python 3 expression: "planet"[1:4]. What value results?

Feedback appears here after you check. This is practice, not a graded school assessment.

See the answer and explanation

'lan'

The sequence is 'planet'. Include positions [1, 2, 3] and exclude endpoint 4; those selected characters give 'lan'. Include the start index and stop before the stated stop index.

Take it further

For text="cabin", expected text[1:4]="abi"at indices 1, 2, 3. The character at index 4 is excluded.

Nothing here is saved to an account or sent to a teacher. The answer download includes your current choice and any checked feedback. It does not include choices from the separate More practice section. Download that section separately.

More practice: try new cases

Choose an answer for each problem. Explain your method on paper, then use the feedback to decide what to revisit.

More practice: try new cases
1. Paper Python 3 expression: "school"[2:5]. What value results?
Need a hint?
  • Include the start index and stop before the stated stop index.
  • Do not include the stop-position character.
2. Paper Python 3 expression: "window"[1:3]. What value results?
Need a hint?
  • Include the start index and stop before the stated stop index.
  • Do not include the stop-position character.
3. Paper Python 3 expression: "pencil"[3:6]. What value results?
Need a hint?
  • Include the start index and stop before the stated stop index.
  • Do not include the stop-position character.

Your choices are temporary. Feedback appears after you check all the answers.

Nothing here is saved to an account or sent to a teacher. Keep your own notes or download them before leaving. The score describes these questions; it does not certify subject mastery.

Check the subject sources

These LifeStarter passages, scenarios and exercises are authored for this Academy with AI assistance and review. External resources keep their publishers’ terms. A grade label suggests a starting level; it does not establish alignment with your school’s complete requirements.