Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么不是';平均值小于0.8时打印的t 6/5_Python - Fatal编程技术网

Python 为什么不是';平均值小于0.8时打印的t 6/5

Python 为什么不是';平均值小于0.8时打印的t 6/5,python,Python,我试图创建一个程序来帮助我计算最终成绩,但当平均值低于0.8时,6/5就不会打印出来 sum1 = 0 input_string = input("Enter decimal grade separated by commas for Maths ") list = input_string.split(",") for num in list: sum1 += float(num) print("Average=", sum1/len(list)) average1=

我试图创建一个程序来帮助我计算最终成绩,但当平均值低于0.8时,6/5就不会打印出来

sum1 = 0

input_string = input("Enter decimal grade separated by commas for     Maths ")
list  = input_string.split(",")
for num in list:
    sum1 +=  float(num)
print("Average=", sum1/len(list))

average1= (sum1/len(list))/10

if average1 >= 0.8:
    print('7');
elif average1 >=0.68:
    print('6');
elif average1 >= 0.55:
    print('5');
else:
    print('not found')
预计产量为0.69,实际产量为0.69

Average= 0.69
6
实际输出为0.69,实际输出为0.69

Average= 0.69
not found

在计算(并打印)平均值后,您将除以10。因此,当它打印
Average=0.69
时,它会尝试查找
0.069
,这太小了,所以它说
找不到
Average=0.69
,然后您管理
average1=Average/10
,这使得
average1==0.069
,当然,您将找不到。在计算average1时,您有一个额外的/10。不要重新定义python保留关键字,list是一个类型,您不应该将它用作变量名。