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

@@ -0,0 +1,11 @@
# 02 — Kolekcje (`list`, `tuple`, `dict`, `set`, slicing)
## Zadania (`collections_ex.py`)
1. `unique_sorted(items: list[int]) -> list[int]` — usuń duplikaty i posortuj rosnąco.
2. `word_counts(text: str) -> dict[str, int]` — policz wystąpienia słów (lowercase).
3. `first_and_last(items: list[str]) -> tuple[str, str] | None` — zwróć pierwszy i ostatni element lub `None` dla pustej listy.
## Uruchomienie testów
```bash
make test MOD=01-core/02-collections
```
@@ -0,0 +1,10 @@
def unique_sorted(items: list[int]) -> list[int]:
raise NotImplementedError("Zwróć posortowaną listę unikalnych elementów")
def word_counts(text: str) -> dict[str, int]:
raise NotImplementedError("Policz wystąpienia słów (case-insensitive)")
def first_and_last(items: list[str]) -> tuple[str, str] | None:
raise NotImplementedError("Zwróć (pierwszy, ostatni) lub None dla pustej listy")
@@ -0,0 +1,18 @@
from collections_ex import first_and_last, unique_sorted, word_counts
def test_unique_sorted() -> None:
assert unique_sorted([3, 1, 2, 3, 1]) == [1, 2, 3]
assert unique_sorted([]) == []
def test_word_counts() -> None:
counts = word_counts("Python python is great and PYTHON works")
assert counts["python"] == 3
assert counts["is"] == 1
def test_first_and_last() -> None:
assert first_and_last([]) is None
assert first_and_last(["only"]) == ("only", "only")
assert first_and_last(["a", "b", "c"]) == ("a", "c")