All problems
Normal Line Slope
Problem
Return the slope of the line normal to f(x) = sum(coeffs[i] * x^i) at x0.
The normal slope is -1 / f'(x0). If f'(x0) == 0 the normal is vertical and the function returns None.
Hint
Perpendicular slopes multiply to -1, so take the negative reciprocal.
Test cases
case 1
in: [[0,0,1],2]
expected: -0.25
case 2
in: [[1,2,1],0]
expected: -0.5
case 3
in: [[5],1]
expected: null
case 4
in: [[0,3],4]
expected: -0.3333333333333333
Starter codePython
def normal_slope(coeffs, x0):
# Return None when f'(x0) == 0
# Your code here
pass4 test cases · run your code against them in the editor