Add CI pipeline for variant 5
This commit is contained in:
1
ci_lab/__init__.py
Normal file
1
ci_lab/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Small utility package for CI laboratory work."""
|
||||
19
ci_lab/math_tools.py
Normal file
19
ci_lab/math_tools.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Mathematical helper functions."""
|
||||
|
||||
def average(numbers: list[float]) -> float:
|
||||
if not numbers:
|
||||
raise ValueError("numbers must not be empty")
|
||||
return sum(numbers) / len(numbers)
|
||||
|
||||
def median(numbers: list[float]) -> float:
|
||||
if not numbers:
|
||||
raise ValueError("numbers must not be empty")
|
||||
sorted_numbers = sorted(numbers)
|
||||
length = len(sorted_numbers)
|
||||
middle = length // 2
|
||||
if length % 2 == 1:
|
||||
return sorted_numbers[middle]
|
||||
return (sorted_numbers[middle - 1] + sorted_numbers[middle]) / 2
|
||||
|
||||
def is_even(number: int) -> bool:
|
||||
return number % 2 == 0
|
||||
16
ci_lab/text_tools.py
Normal file
16
ci_lab/text_tools.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""Text helper functions."""
|
||||
|
||||
def normalize_text(text: str) -> str:
|
||||
return " ".join(text.lower().split())
|
||||
|
||||
def word_count(text: str) -> int:
|
||||
normalized = normalize_text(text)
|
||||
if not normalized:
|
||||
return 0
|
||||
return len(normalized.split(" "))
|
||||
|
||||
def unique_words(text: str) -> set[str]:
|
||||
normalized = normalize_text(text)
|
||||
if not normalized:
|
||||
return set()
|
||||
return set(normalized.split(" "))
|
||||
Reference in New Issue
Block a user