z-score and normal probability

Values follow a normal distribution with a given mean and standard deviation. For a value x, print its z-score and the probability that a value is at most x.

Input

One line: mean, sd (greater than 0) and x, as decimals.

Output

Two lines: z Z to 2 decimal places and P(X<=x) P to 4 decimal places.

Examples

Example 1 · Input
70 8 82
Expected output
z 1.50
P(X<=x) 0.9332
Example 2 · Input
100 15 100
Expected output
z 0.00
P(X<=x) 0.5000

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

Hints

Hint 1

z = (x − mean) ÷ sd.

Hint 2

P(X ≤ x) = 0.5 × (1 + erf(z ÷ √2)), with erf from the math module.

Solution

Show one correct solution (try it yourself first)
from math import erf, sqrt
mean, sd, x = map(float, input().split())
z = (x - mean) / sd
print(f"z {z:.2f}")
print(f"P(X<=x) {0.5 * (1 + erf(z / sqrt(2))):.4f}")

Lesson: The normal distribution →