FunctionRacerProblemsRace

Trend Slope

EasyNumPyPython

Treat values[i] as the height of a point at x = i. Return the slope of the best-fit straight line through all the points, as a float. Hint: np.polyfit(x, values, 1) returns the slope first.

Example 1

values [1,3,5,7]
returns 2.0

The points lie exactly on a line that rises 2 per step.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems