A 95% interval from a summary

A study reports a sample's size, mean and standard deviation. Turn them into a 95% confidence interval.

What to build

A program that prints a standard error and a 95% confidence interval.

Requirements

  • Print standard error S (3 decimal places) and 95% CI: L to U (2 decimal places).

Input

One line: n, the mean and the sample standard deviation.

Output

Two lines.

Constraints

2 ≤ n ≤ 10⁶; the standard deviation is at least 0.

Example

Input:

25 169.6 5.8

Output:

standard error 1.160
95% CI: 167.33 to 171.87

Why it works

95% of a normal curve lies within 1.96 standard deviations of its centre, and the sample mean's standard deviation is the standard error.

Examples

Example 1 · Input
25 169.6 5.8
Expected output
standard error 1.160
95% CI: 167.33 to 171.87
Example 2 · Input
100 50 10
Expected output
standard error 1.000
95% CI: 48.04 to 51.96

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

The standard error is sd ÷ √n.

Hint 2

The interval is mean − 1.96 × SE to mean + 1.96 × SE.

Solution

Show one correct solution (try it yourself first)
n, mean, sd = map(float, input().split())
se = sd / n ** 0.5
print(f"standard error {se:.3f}")
print(f"95% CI: {mean - 1.96 * se:.2f} to {mean + 1.96 * se:.2f}")

Lesson: Confidence intervals →