20 lines
420 B
Python
20 lines
420 B
Python
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)) |