seed: curriculum content
This commit is contained in:
37
1.solar-system/2.first-light/06.the-translator/index.md
Normal file
37
1.solar-system/2.first-light/06.the-translator/index.md
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Translator"
|
||||
xp: 50
|
||||
duration: 25
|
||||
difficulty: 2
|
||||
---
|
||||
|
||||
# The Translator
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, when input comes in as text (a `str`), you can't do math
|
||||
> with it directly. You have to *translate* it to a number.
|
||||
>
|
||||
> Three converters:
|
||||
>
|
||||
> - `int("42")` → `42`
|
||||
> - `float("3.14")` → `3.14`
|
||||
> - `str(42)` → `"42"`
|
||||
>
|
||||
> Implement `years_until(age)` that returns `100 - age` as an `int`.
|
||||
> The argument may arrive as either `int` or `str` — handle both
|
||||
> by calling `int()` on it first.
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
Open `starter/starter.py`. Convert `age` with `int()`, then return
|
||||
`100 - age`.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `years_until(25)` returns `75`
|
||||
- `years_until("25")` also returns `75` (handles string input)
|
||||
- Works for any integer age 0–100
|
||||
Reference in New Issue
Block a user