From 51682d8972650f22b48ed47394b730cff7e288e9 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 10 Mar 2026 16:09:59 +0300 Subject: [PATCH] add files --- equation_of_line.py | 20 ++++++++++++++++++++ linalg1.py | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 equation_of_line.py create mode 100644 linalg1.py diff --git a/equation_of_line.py b/equation_of_line.py new file mode 100644 index 0000000..abd87ca --- /dev/null +++ b/equation_of_line.py @@ -0,0 +1,20 @@ +def equation_of_line(values): + b = values[0] + k = values[1] - b + + if any(y != k * x + b for x, y in enumerate(values, 0)): + return + + res = "" + + if k: + res += f"{'-' if k == -1 else k != 1 and k or ''}x" + + if b: + res += (res and " ") + "+-"[b < 0] + str(abs(b)) + return f"y = {res}" + + + +v = [0, -1, -2, -3, -4] +print(equation_of_line(v)) \ No newline at end of file diff --git a/linalg1.py b/linalg1.py new file mode 100644 index 0000000..945e579 --- /dev/null +++ b/linalg1.py @@ -0,0 +1,19 @@ +from math import sqrt + + +def find_discr(a, b, c): + return b**2 - 4 * a * c + + +def solve_sq(a, b, c): + d = find_discr(a, b, c) + if d < 0: + return + if d == 0: + return -b / (2 * a) + return tuple( + (-b + s * sqrt(d)) / (2 * a) + for s in [-1, 1] + ) + +