All problems
Guardrail Block Rate
Problem
Return the fraction of decisions that block a response, where decisions is a list of booleans with True meaning blocked.
Return 0.0 for an empty list.
Hint
Count the True values and divide by the list length.
Test cases
case 1
in: [[true,false,true,true]]
expected: 0.75
case 2
in: [[]]
expected: 0
case 3
in: [[false]]
expected: 0
case 4
in: [[true]]
expected: 1
case 5
in: [[true,false]]
expected: 0.5
Starter codePython
def guardrail_block_rate(decisions):
# Your code here
pass5 test cases · run your code against them in the editor