Area Under the Points
The points (xs[i], ys[i]) are joined by straight lines, with xs increasing. Return the area between that line and the x axis (the trapezoid rule). Parts below the axis count as negative.
Example 1
xs [0,1,2]
ys [0,1,0]
returns 1.0
A triangle with base 2 and height 1.
Constraints
2 <= len(xs) <= 40xsis strictly increasing
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More SciPy problems
- Chance of at MostBeginner
- City Block DistanceBeginner
- Percent at or BelowBeginner
- Standard ErrorBeginner
- Standard ScoresBeginner
- The ModeBeginner
- Which Way It LeansBeginner
- At Least K WinsEasy