All problems
Peak-to-Average Ratio
Problem
Compute the peak-to-average ratio of a load profile: max(load) / mean(load).
Return 0.0 for an empty series or a zero mean.
Hint
A flatter profile has a ratio closer to 1.
Test cases
case 1
in: [[1,2,3,4]]
expected: 1.6
case 2
in: [[5,5,5]]
expected: 1
case 3
in: [[1,0,0]]
expected: 3
case 4
in: [[0,0]]
expected: 0
Starter codePython
def peak_to_average_ratio(load):
# Your code here
pass4 test cases · run your code against them in the editor