---
# System prepended metadata

title: 311159023徐若曦_程式設計wk14上課資料

---

# 311159023徐若曦_程式設計wk14上課資料
## Python
### depsta.py
#### 程式設計
```
import math

def depsta(sample):
    # depsta 功能：計算樣本的敘述統計
    maxv=max(sample)
    minv=min(sample)
    meanv=sum(sample)/len(sample)
    sumi=0
    for i in range(0, len(sample)):
        sumi=sumi+((sample[i]-meanv)**2)
    varv=sumi/len(sample)+1
    stdv=math.sqrt(varv)
    return(maxv, minv, meanv, varv, stdv)

sample=[5, 8, 9, 6, 4, 1, 5, 3, 6, 2]

print("max=%2.1f,min=%2.1f,mean=%2.1f,var=%2.1f,std=%2.1f" %(depsta(sample)))
```
#### 執行結果
```
max=9.0,min=1.0,mean=4.9,var=6.7,std=2.6
```