seed: curriculum content

This commit is contained in:
2026-05-07 14:32:44 +00:00
parent 9258534803
commit ec76f4f56b
100 changed files with 2846 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
---
type: challenge
title: "The Message"
xp: 50
duration: 25
difficulty: 2
---
# The Message
> **[INCOMING — Mission Control, Earth]**
>
> Cadet, a string is a *sequence of characters*. You can pick any
> one out by its position (its *index*).
>
> Indexes start at 0:
>
> ```
> M I S S I O N
> 0 1 2 3 4 5 6
> ```
>
> Negative indexes count back from the end. `s[-1]` is the last
> character.
>
> Strings are *immutable* — you can read any character, but you can't
> change one in place. To "modify" a string, you build a new one.
>
> Implement `info(s)` that returns a dict with four keys: `first`,
> `sixth`, `last`, `length`.
>
> [END TRANSMISSION]
## Your Task
Open `starter/starter.py`. Use `s[0]`, `s[5]`, `s[-1]`, and `len(s)`
to fill in the dict.
## Objectives
- `info("MISSION-CONTROL-7")` returns `{"first": "M", "sixth": "O", "last": "7", "length": 17}`
- Works for any non-empty string of length ≥ 6

View File

@@ -0,0 +1,13 @@
def info(s):
"""Return a dict describing the string s.
Keys:
"first" — the character at index 0
"sixth" — the character at index 5
"last" — the character at index -1
"length" — total number of characters
info("MISSION-CONTROL-7") -> {"first": "M", "sixth": "O",
"last": "7", "length": 17}
"""
pass

View File

@@ -0,0 +1,16 @@
from solution import info
def test_mission_control():
r = info("MISSION-CONTROL-7")
assert r == {"first": "M", "sixth": "O", "last": "7", "length": 17}
def test_andromeda():
r = info("andromeda")
assert r == {"first": "a", "sixth": "m", "last": "a", "length": 9}
def test_alphabet():
r = info("ABCDEFGH")
assert r == {"first": "A", "sixth": "F", "last": "H", "length": 8}