chore: initialize containerized Python learning workbook (2026 DevOps/SRE)

This commit is contained in:
soda64 committed 2026-11-30 22:55:56 +01:00
commit ae4c421815
63 files changed
+1273

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# 01 — Podstawy (zmienne, warunki, pętle, funkcje)
## Zadania (`basics.py`)
1. `celsius_to_fahrenheit(c: float) -> float` — przelicz temperaturę ($F = C \cdot 1.8 + 32$).
2. `classify_score(score: int) -> str` — `0..49` -> `"fail"`, `50..74` -> `"pass"`, `75..89` -> `"good"`, `90..100` -> `"excellent"`, inaczej `"invalid"`.
3. `sum_up_to(n: int) -> int` — suma liczb od `1` do `n` włącznie (dla `<= 0` zwróć `0`).
4. `fizzbuzz_label(n: int) -> str` — `"Fizz"`, `"Buzz"`, `"FizzBuzz"` lub `str(n)`.
## Uruchomienie testów
```bash
make test MOD=01-core/01-basics
```
+14
View File
@@ -0,0 +1,14 @@
def celsius_to_fahrenheit(c: float) -> float:
raise NotImplementedError("Przelicz Celsjusze na Fahrenheity: c * 1.8 + 32.0")
def classify_score(score: int) -> str:
raise NotImplementedError("Sklasyfikuj wynik 0..100 lub zwróć 'invalid'")
def sum_up_to(n: int) -> int:
raise NotImplementedError("Zsumuj liczby od 1 do n włącznie")
def fizzbuzz_label(n: int) -> str:
raise NotImplementedError("Zwróć Fizz / Buzz / FizzBuzz lub str(n)")
@@ -0,0 +1,30 @@
import pytest
from basics import celsius_to_fahrenheit, classify_score, fizzbuzz_label, sum_up_to
def test_celsius_to_fahrenheit() -> None:
assert celsius_to_fahrenheit(0.0) == pytest.approx(32.0)
assert celsius_to_fahrenheit(100.0) == pytest.approx(212.0)
assert celsius_to_fahrenheit(-40.0) == pytest.approx(-40.0)
def test_classify_score() -> None:
assert classify_score(0) == "fail"
assert classify_score(50) == "pass"
assert classify_score(80) == "good"
assert classify_score(95) == "excellent"
assert classify_score(101) == "invalid"
assert classify_score(-1) == "invalid"
def test_sum_up_to() -> None:
assert sum_up_to(0) == 0
assert sum_up_to(-5) == 0
assert sum_up_to(10) == 55
def test_fizzbuzz_label() -> None:
assert fizzbuzz_label(1) == "1"
assert fizzbuzz_label(3) == "Fizz"
assert fizzbuzz_label(5) == "Buzz"
assert fizzbuzz_label(15) == "FizzBuzz"