seed: curriculum content
This commit is contained in:
40
1.solar-system/2.first-light/05.the-vault/index.md
Normal file
40
1.solar-system/2.first-light/05.the-vault/index.md
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Vault"
|
||||
xp: 50
|
||||
duration: 25
|
||||
difficulty: 1
|
||||
---
|
||||
|
||||
# The Vault
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, every program needs to remember things. Variables hold
|
||||
> values; types tell Python what kind of value:
|
||||
>
|
||||
> - `int` — whole numbers, like `3`
|
||||
> - `float` — decimals, like `4500.5`
|
||||
> - `str` — text in quotes, like `"Apollo"`
|
||||
> - `bool` — `True` or `False`
|
||||
>
|
||||
> A **dictionary** maps keys to values. Implement a function `vault`
|
||||
> that returns a dictionary with exactly these four keys and values:
|
||||
>
|
||||
> ```
|
||||
> "mission": "Apollo"
|
||||
> "crew_size": 3
|
||||
> "fuel_kg": 4500.5
|
||||
> "ready": True
|
||||
> ```
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
Open `starter/starter.py`. Replace `pass` with `return { ... }`.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `vault()` returns a dict
|
||||
- Each key holds the exact value above (and the right type)
|
||||
@@ -0,0 +1,9 @@
|
||||
def vault():
|
||||
"""Return a dictionary with these four keys and exact values:
|
||||
|
||||
"mission": "Apollo" (str)
|
||||
"crew_size": 3 (int)
|
||||
"fuel_kg": 4500.5 (float)
|
||||
"ready": True (bool)
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,29 @@
|
||||
from solution import vault
|
||||
|
||||
|
||||
def test_returns_dict():
|
||||
assert isinstance(vault(), dict)
|
||||
|
||||
|
||||
def test_mission_is_correct_string():
|
||||
v = vault()
|
||||
assert v["mission"] == "Apollo"
|
||||
assert isinstance(v["mission"], str)
|
||||
|
||||
|
||||
def test_crew_size_is_correct_int():
|
||||
v = vault()
|
||||
assert v["crew_size"] == 3
|
||||
assert isinstance(v["crew_size"], int)
|
||||
assert not isinstance(v["crew_size"], bool)
|
||||
|
||||
|
||||
def test_fuel_kg_is_correct_float():
|
||||
v = vault()
|
||||
assert v["fuel_kg"] == 4500.5
|
||||
assert isinstance(v["fuel_kg"], float)
|
||||
|
||||
|
||||
def test_ready_is_true_bool():
|
||||
v = vault()
|
||||
assert v["ready"] is True
|
||||
Reference in New Issue
Block a user