|
1 | | -# Exercise 02 - Datatypes |
| 1 | +# Exercise 02 — Space Station Diagnostic System |
2 | 2 |
|
3 | 3 | ## Description |
4 | | -Welcome to your first real excercise. In the last one, we checked if everything is working correctly, now its time to put your knowlege to test. This and feature excercises contain multiple tests which are skipped by default (only first one is enabled). Your job is to finish one thing at a time and run the test. To run the next test, go to `test_<lesson_name>.py` and remove the `@pytest.mark.skip` line from the next test. Your goal is to make all tests pass. |
| 4 | +Welcome aboard the ORION-9 deep-space research station! The central terminal suffered a reboot after a cosmic flare. Before life support and navigation systems can come back online, you must manually declare and initialize the core system variables. |
5 | 5 |
|
6 | | -In this excercise you will define datatypes we talked about in lesson: **String**, **Integer**, **Float**, **Boolean**, **None**. |
| 6 | +This exercise will guide you through Python's core data types: **String**, **Integer**, **Float**, **Boolean**, and **None**, along with basic type casting and printing. |
7 | 7 |
|
8 | | -You need to define the following variables: |
9 | | -* `mystring` - set it to some string |
10 | | -* `myinteger` - set it to some integer |
11 | | -* `myfloat` - set it to some float |
12 | | -* `myboolean` - set it to some boolean |
13 | | -* `mynonevalue` - set it to some None |
| 8 | +--- |
14 | 9 |
|
15 | | -You need to make sure the variables are named **exactly** like written here, otherwise the tests will fail, values can be anything you want. |
| 10 | +## Tasks |
16 | 11 |
|
17 | | -### Run the tests |
18 | | -To run the tests, run the following command in the directory root (`python-excercises`): |
| 12 | +### Task 1: Initialize System Identity |
| 13 | +Declare the station's core identification variables: |
| 14 | +* `station_name` — a **string** representing the station name (e.g., `"Orion 9"`) |
| 15 | +* `module_count` — an **integer** representing active station modules (e.g., `12`) |
| 16 | +* `signal_frequency` — a **float** representing the sub-space signal frequency (e.g., `1420.405`) |
| 17 | +* `life_support_active` — a **boolean** set to `True` |
| 18 | +* `backup_generator` — set to `None` (representing an offline component) |
| 19 | + |
| 20 | +> **Next step:** Run the test suite. If `test_task_1` passes, open `test_core_datatypes.py` and remove the `@pytest.mark.skip` line above `test_task_2`. |
| 21 | +
|
| 22 | +### Task 2: Type Casting & Calibration |
| 23 | +The telemetry unit sent data in the wrong format! Fix the formats using type casting: |
| 24 | +* `raw_energy_reading` is provided as `"100"` (a string). Create a new variable `energy_level` by casting `raw_energy_reading` to an **integer**. |
| 25 | +* `raw_distance_reading` is provided as `45` (an integer). Create a new variable `exact_distance` by casting `raw_distance_reading` to a **float**. |
| 26 | +* `raw_status_code` is provided as `1` (an integer). Create a new variable `is_operational` by casting `raw_status_code` to a **boolean**. |
| 27 | + |
| 28 | +> **Next step:** Run the test suite. If `test_task_2` passes, open `test_core_datatypes.py` and remove the `@pytest.mark.skip` line above `test_task_3`. |
| 29 | +
|
| 30 | +### Task 3: Terminal Broadcast |
| 31 | +* Create a variable `station_status` by converting `module_count` to a string and concatenating it with `station_name` (e.g., `"12 - Orion 9"`). |
| 32 | +* Print `station_status` to the terminal console using the `print()` function. |
| 33 | + |
| 34 | +> **Next step:** Run the test suite. If `test_task_3` passes, congrats! You have completed then exercise. |
| 35 | +
|
| 36 | +--- |
| 37 | + |
| 38 | +## How to Run the Tests |
| 39 | +Run the following command from the root directory: |
19 | 40 | ```bash |
20 | 41 | python check.py 02 |
21 | 42 | ``` |
22 | 43 |
|
23 | | -## Notes |
24 | | -To finish this excercise, visit our first lesson in TPL - [Datatypes](https://thepythonledger.github.io/Docusaurus-engine/lessons/python-foundations/core-datatypes) |
| 44 | +## Resources |
| 45 | +Review the core concepts in [The Python Ledger lesson on Core Datatypes](https://thepythonledger.github.io/Docusaurus-engine/lessons/python-foundations/core-datatypes). |
0 commit comments