From 530fb44198799782c58ea1144f3989481fc58478 Mon Sep 17 00:00:00 2001 From: SeanChang8 <34203468+SeanChang8@users.noreply.github.com> Date: Mon, 11 Dec 2017 17:05:38 +0800 Subject: [PATCH] p13 --- p13.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 p13.py diff --git a/p13.py b/p13.py new file mode 100644 index 0000000..b2d7f82 --- /dev/null +++ b/p13.py @@ -0,0 +1,14 @@ +import math +nlist=[7, 38, 4, 23, 18] +N=len(nlist) +sum1=0 +sum2=0 +for i in range(N): + sum1+=nlist[i] + sum2+=nlist[i]**2 +mean=sum1/N +var=sum2/N-mean**2 +print(N) +print('The Expectation / Mean:', format(mean , '.1f')) +print('The Variance is:', format(var , '.1f')) +print('The Standard Deviation is:', format(math.sqrt(var) , '.1f'))