import math f = lambda x, a, b, c, d: a / (1 + math.exp(-b - c * x - d * x**2)) def calc_and_save(a, b, c, d, filename="results.txt"): xs = [x for x in range(-20, 21, 2)] values = [f(x, a, b, c, d) for x in xs] with open(filename, "w", encoding="utf-8") as file: for i, val in enumerate(values, start=1): file.write(f"{val:.6f}") if i % 3 == 0: file.write("\n") else: file.write(" ")