Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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 混淆名称错误_Python_Python 3.2 - Fatal编程技术网

Python 混淆名称错误

Python 混淆名称错误,python,python-3.2,Python,Python 3.2,我有个问题。我在下面运行了这个程序,得到了一个不寻常的错误,说“mean”这个名字没有定义。以下是错误: Traceback (most recent call last): File "C:/Python32/Computer science stuff/PracticeTest 175-183.py", line 45, in <module> main() File "C:/Python32/Computer science stuff/PracticeTest

我有个问题。我在下面运行了这个程序,得到了一个不寻常的错误,说“mean”这个名字没有定义。以下是错误:

Traceback (most recent call last):
  File "C:/Python32/Computer science stuff/PracticeTest 175-183.py", line 45, in <module>
    main()
  File "C:/Python32/Computer science stuff/PracticeTest 175-183.py", line 44, in main
    displaySummary()
  File "C:/Python32/Computer science stuff/PracticeTest 175-183.py", line 23, in displaySummary
    print("List's mean: " + str(mean))
NameError: global name 'mean' is not defined

calculateMean()
函数的结果分配给
mean
局部变量:

mean = calculateMean(a, b, c, d, e)
print("The values used: " + str(a) + " " + str(b) + " " + str(c) + " " +     str(d) + " " + str(e))
print("List's mean: " + str(mean))

print(“列表的平均值:”+str(平均值))
mean未在此行定义。变量范围仅限于函数
calculateMean
,从函数外部看,您的程序“不知道”该变量。请尝试
mean=calculateMean(a、b、c、d、e)
mean
显示摘要
中的自由变量。你可能是想把它绑在什么东西上。谢谢大家帮我找到了问题所在
mean = calculateMean(a, b, c, d, e)
print("The values used: " + str(a) + " " + str(b) + " " + str(c) + " " +     str(d) + " " + str(e))
print("List's mean: " + str(mean))