Can anyone tell me why i can't compare the value of a function and a float/number.
# Everything is fine except 7th line from last...it is showing that type error. def get_y(m, b, x): y = m*x + b return y #Write your calculate_error function here def calculate_error(m,b,point): x_point =point[0] y_point =point[1] return abs(get_y(m,b,x_point) - y_point) datapoints = [(1, 2), (2, 0), (3, 4), (4, 4), (5, 3)] #Write your calculate_all_errodr function here def calculate_all_error(m,b,points): k=0 for z in points: calculate_error(m,b,z) k=k+calculate_error(m,b,z) return k possible_ms = a=[-10 + 0.1 * x for x in range(int((10-(-10))/0.1)+1)] possible_bs = a=[-10 + 0.1 * x for x in range(int((20-(-20))/0.1)+1)] smallest_error=float("inf") best_m=0 best_b=0 for m in possible_ms: for b in possible_bs: if calculate_all_error(m,b,datapoints) < smallest_error: best_m=m best_b=b smallest_error=calculate_all_error print(best_m) print(best_b) print(smallest_error)