#algebra.py def build_polynomial_f(*args): '''Return a polynomial function up to degree 4 ''' if len(args) == 5: #quartic return lambda x: args[0]*x**4 +args[1]*x**3 + args[2]*x**2 + args[3]*x + args[4] elif len(args) == 4: #cubic return lambda x: args[0]*x**3 +args[1]*x**2 + args[2]*x + args[3] elif len(args) == 3: #quadratic return lambda x: args[0]*x**2 +args[1]*x + args[2] elif len(args) == 2: #linear return lambda x: args[0]*x + args[1] elif len(args) == 1: #constant return lambda x: args[0] fc1 = build_polynomial_f(2,-3,5,-3) print(fc1(0)) print(fc1(1)) fq1 = build_polynomial_f(3,-2,1) print(fq1(2)) print(fq1(-2))