seed: curriculum content
This commit is contained in:
43
1.solar-system/2.first-light/03.the-repl/index.md
Normal file
43
1.solar-system/2.first-light/03.the-repl/index.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The REPL"
|
||||
xp: 25
|
||||
duration: 25
|
||||
difficulty: 1
|
||||
---
|
||||
|
||||
# The REPL
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, the *REPL* — Read, Evaluate, Print, Loop — is Python's
|
||||
> interactive shell. Open it on your machine with `python3` and
|
||||
> every line you type runs immediately:
|
||||
>
|
||||
> ```
|
||||
> >>> 5 + 7
|
||||
> 12
|
||||
> >>> "Hello".upper()
|
||||
> 'HELLO'
|
||||
> ```
|
||||
>
|
||||
> Use the REPL to figure out the answers. Then write them into a
|
||||
> function `compute` that returns a tuple of all five, in order:
|
||||
>
|
||||
> 1. `5 + 7`
|
||||
> 2. `100 - 25`
|
||||
> 3. `6 * 8`
|
||||
> 4. `"Hello" + " " + "World"`
|
||||
> 5. `2 ** 10`
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
Open `starter/starter.py`. Replace `pass` with a `return` of a
|
||||
5-element tuple containing the values above.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `compute()` returns a 5-element tuple
|
||||
- Each element matches the corresponding expression
|
||||
10
1.solar-system/2.first-light/03.the-repl/starter/starter.py
Normal file
10
1.solar-system/2.first-light/03.the-repl/starter/starter.py
Normal file
@@ -0,0 +1,10 @@
|
||||
def compute():
|
||||
"""Return a tuple of 5 computed values, in this order:
|
||||
|
||||
1. 5 + 7
|
||||
2. 100 - 25
|
||||
3. 6 * 8
|
||||
4. "Hello" + " " + "World"
|
||||
5. 2 ** 10
|
||||
"""
|
||||
pass
|
||||
@@ -0,0 +1,25 @@
|
||||
from solution import compute
|
||||
|
||||
|
||||
def test_returns_five_values():
|
||||
assert len(compute()) == 5
|
||||
|
||||
|
||||
def test_first_is_addition():
|
||||
assert compute()[0] == 12
|
||||
|
||||
|
||||
def test_second_is_subtraction():
|
||||
assert compute()[1] == 75
|
||||
|
||||
|
||||
def test_third_is_multiplication():
|
||||
assert compute()[2] == 48
|
||||
|
||||
|
||||
def test_fourth_is_string_concat():
|
||||
assert compute()[3] == "Hello World"
|
||||
|
||||
|
||||
def test_fifth_is_power():
|
||||
assert compute()[4] == 1024
|
||||
Reference in New Issue
Block a user