Margin of Error for a Poll
Brightpath Civic runs opinion polling for city councils. A council deciding whether to fund a policy commissions a poll: some number of residents are asked, and some share of them say they support it. The council's press office wants to publish the figure with the usual "plus or minus" attached, and it has to be the right one.
A support here means a resident who answered yes; everyone else, including the undecided, counts against. Brightpath reports every question on every poll this way, at whatever confidence level the client's style guide uses, so the critical value arrives with the job.
Task: Print the margin of error for the support figure, rounded to 4 decimals. The conventions: this is the ordinary normal-approximation interval built around the observed share, not a Wilson or exact interval; the answer is on the proportion scale, so 0.05 would mean five percentage points; it is the half-width, not the total span; the interval is two-sided; and rounding happens once, on the final value.
Input
Three lines: how many residents were asked, the observed share who said yes as a decimal between 0 and 1, and the critical value for the confidence level being published. The count is a whole number of at least 1.
Output
One line holding the margin of error on the proportion scale, rounded to 4 decimals and printed the way Python prints a float - 0.048, never 0.0480.
Example:
Input:
400
0.6
1.96
Output:
0.048
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in