/
Nik_voz
/
rgpu_python_analysis
Обзор
Документация
Войти
/
Nik_voz
/
rgpu_python_analysis
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
python_analysis/functions_.py
64 строки
2 KB
«Nick-voz»
fix(python_analysis): Correct import path for is_simple in functions_.py
29 мар 2025, 09:52
29 мар 2025, 09:52
61dee99
Код
Авторство
О чём код?
from math import sqrt from python_analysis.lists_ import is_simple def functions_1(n: int) -> int: return sum(map(int, str(n))) def oct_to_dec(s: str) -> int: # return int("s", 8) # return sum((int(e) * 8**i for i, e in enumerate(reversed(list(s))))) res = 0 for i, e in enumerate(reversed(list(s))): res += int(e) * 8**i return res def functions_2(s: str) -> int: return sum(map(oct_to_dec, s.split("+"))) def functions_3(points: list[tuple[float, float]]) -> float: # def dist(*points: iterable[float]) -> float # just because I wanna write function inside of the another function at this moment def dist(x_1: float, y_1: float, x_2: float, y_2: float) -> float: return sqrt((x_1 - x_2) ** 2 + (y_1 - y_2) ** 2) # at list it was funny p = points return sum(map(lambda x: dist(*(x[0] + x[1])), zip(p[:-1], p[1:]))) # more complicated version # return sum( # map(lambda x: dist(*x), map(lambda x: x[0] + x[1], zip(p[:-1], p[1:]))) # ) # wit dist() into map # return sum( # map( # lambda x: sqrt( # (x[0][0] - x[1][0]) ** 2 + (x[0][1] - x[1][1]) ** 2 # ), # zip(p[:-1], p[1:]), # ), # ) def functions_4(a: int, b: int) -> list[int]: return [e for e in range(a, b + 1) if is_simple(e)] def functions_5( _index: list[dict[int, tuple[str, str]]], author: str ) -> list[dict[int, str]]: res: list[dict[int, str]] = [] for row in _index: code, *_ = row.keys() _author, book = row[code] if _author == author: res.append({code: book}) return res