All problems
Margin of Error Proportion
Problem
The margin of error for a proportion is z * sqrt(p_hat (1 - p_hat) / n).
Given the sample proportion, sample size, and critical z, return the margin.
Hint
It is half the Wald interval width.
Test cases
case 1
in: [0.5,400,1.96]
expected: 0.049
case 2
in: [0.2,100,2.576]
expected: 0.10304
case 3
in: [0.75,1000,1.645]
expected: 0.022525090177399957
Starter codePython
def margin_of_error_proportion(p_hat, n, z):
# Your code here
pass3 test cases · run your code against them in the editor