大学物理实验不确定度A和C


求不确定度A加B


```python
#!/usr/bin/python
# -*- coding:utf-8 -*-
from math import sqrt
class Data():
    def __init__(self):
        self.data = []

        self.n = 0
    def addphysicsdata(self):
        self.data.clear()
        self.n = int(input("有几个数据:"))
        print("请输入 %d 次"%self.n)

        for i in range(self.n):
            self.data.append(float(input()))

    def showdata(self):
        print(self.data)
    def average(self):
        return sum(self.data)/self.n

    def A_difference(self):

        ave = self.average()
        ins = float(input("不确定度Ub为:"))
        Ua= math.sqrt(sum(list(map(lambda x: (x - ave) ** 2, self.data))) / (self.n * (self.n - 1)))
        Uc= (Ua**2+ins**2)**1/2
        print("A类不确定度为:%lf"%(Ua))
        print("C类不确定度为:%lf"%(Uc))
    def showAll(self):
        self.showdata()
        print('平均:'+str(self.average()))
        self.A_difference()

def shi():
    data = Data()
    while (True):
        print('1:输入,2:显示结果,0:退出')
        key = int(input())
        if (key == 1):
            data.addphysicsdata()
        elif (key == 2):
            data.showAll()
        elif (key == 0):
            break
if __name__ =='__main__':
    shi()


[exe文件下载地址](%E9%93%BE%E6%8E%A5:%20https://pan.baidu.com/s/1nXTLqa6FU2JwqCvAB3Thhw%20%E6%8F%90%E5%8F%96%E7%A0%81:%202713)
链接: https://pan.baidu.com/s/1nXTLqa6FU2JwqCvAB3Thhw 提取码: 2713

你可能感兴趣的:(大学物理实验不确定度A和C)