← Back to course
Code Crew G4 / Week 05 / Crew Quest
6/6
Week 05 Β· Strings up close

Crew Quest

Crew Quest: Letter Tiles
// Letter by letter
⏱ about 15 min

Crew Quest: Letter Tiles

Raven cuts a strip of paper into small squares. On each square she writes one letter: S, T, A, R, L, I, G, H, T. "This is a string," she says.

Rocket picks up two pencils and lays them across the strip like brackets. "And this is a slice!" he laughs.

Nova hovers close. "What do you notice about the index of the first square?" she asks. "Zero!" they both say at once.

  1. A string is a row of characters. Spaces count.
  2. len counts characters. Index 0 is the first one, and -1 is the last.
  3. A slice like word[0:3] starts at the first number and stops before the second.
  4. upper and lower make a copy with capitals or small letters.
  5. in checks if one string is inside another. Capitals matter.
β—‡ LETTER TILES
Cut a strip of paper into nine squares.
Write STARLIGHT, one letter per square. Number them 0 to 8.
Your partner says a slice, like [4:9]. Lay two pencils to show it.
Read the slice out loud. Then swap jobs.
Bonus: find the slice that spells STAR.
word = "STARLIGHT"
print(word[4:9])
print(word[0:4].lower())
First line on the screen
Second line on the screen
BONUS RECAP
  • Read the question.
  • Tap your answer.
What does len("a b") give?
What is "SPACE"[1:3]?
What does "Go" in "go now" give?

Terrific work this week! Next week, you will decode the station's garbled comms log.

← Friday