little fix

This commit is contained in:
2024-12-03 23:01:46 +01:00
parent c1626d4008
commit 034d6883bf

View File

@@ -7,25 +7,20 @@ import random as rand
def print_table(*columns, result):
headers = ["Lp.", "x0", "x1", "x2", "x0y", "x1y"]
# Combine headers and columns to calculate max width for each column
max_widths = [
max(len(str(cell)) for cell in [header] + list(column))
for header, column in zip(headers, columns)
]
# Function to format a row
def format_row(row):
return " | ".join(f"{str(cell).ljust(width)}" for cell, width in zip(row, max_widths))
# Print header
print(format_row(headers))
print("-" * (sum(max_widths) + 3 * (len(headers) - 1))) # Separator line
# Print rows
for row in zip_longest(*columns, fillvalue=" "):
print(format_row(row))
# Print result at the bottom
print("-" * (sum(max_widths) + 3 * (len(headers) - 1)))
print(", ".join(result), end="\n\n")
@@ -71,7 +66,7 @@ a0 = a0(a1)
print(f"a0 = {round(a0, 2)}, a1 = {round(a1, 2)}")
# rysowanie funkcji i punktów
plt.xlabel('oś x')
plt.ylabel('oś y')
plt.title('Aproksymacja - MNK')