All problems
Failure Rate From Counts
Problem
Estimate the failure rate from failures observed over total_time units of operation:
rate = failures / total_time.
Return 0.0 when total_time <= 0.
Hint
For exponential lifetimes the failure rate is the reciprocal of the MTBF.
Test cases
case 1
in: [3,1000]
expected: 0.003
case 2
in: [0,500]
expected: 0
case 3
in: [7,2]
expected: 3.5
case 4
in: [0,0]
expected: 0
Starter codePython
def failure_rate_from_counts(failures, total_time):
# Your code here
pass4 test cases · run your code against them in the editor