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