def p(s):print(s)
def f():
n=int(input("n:"))
s=0.0
for i in range(n):
s+=float(input(">"))
p("m="+str(s/n))
f()Tier 1 · statistics
Mean
Arithmetic mean of n values.
Files (1)
How to use it
Launch MEAN from prgm. The program runs once (no menu).
n:— enter how many numbers you're averaging.>— type the first value,enter.- Keep pressing
>for each subsequent value.
After the last value, output is m= with the arithmetic mean. Program exits automatically.
Example problem
Your last three quiz scores were 80, 90, and 100. What's your average?
- Run
MEAN. n:→ 3.>→ 80,enter.>→ 90,enter.>→ 100,enter.- Output:
m=90.0.
Average is 90. Verify: (80+90+100)/3 = 270/3 = 90. ✓
TI-84 Plus CE — try before committingoff
TI-84 Plus CE
(calculator off) Press ON to start.
Test cases (1)
| ID | Inputs | Expected contains |
|---|---|---|
| three-nums | 3, 2, 4, 6 | m=4.0 |