add files

This commit is contained in:
2026-03-10 16:09:59 +03:00
parent d66ec02d68
commit 51682d8972
2 changed files with 39 additions and 0 deletions

20
equation_of_line.py Normal file
View File

@@ -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))

19
linalg1.py Normal file
View File

@@ -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]
)