我是python的新手。从2013年开始在大学学习以来,我一直在努力学习以了解python的工作原理。抱歉,如果有点乱。在
让我在下面展示我的问题。
我有一些def函数,看起来像:def thread_1():
a = input('Value UTS (100) = ')
if a > 100:
print line2
d=raw_input('Dont higher than 100. Input y to repeat : ')
d='y'
if d=='y' :
thread_1()
return a
def thread_2():
b = input('Value UAS (100) = ')
if b > 100:
print line2
d=raw_input('Dont higher than 100. Input y to repeat : ')
d='y'
if d=='y' :
thread_2()
return b
def thread_3():
c = input('Value Course (100) = ')
if c > 100:
print line2
d=raw_input('Dont higher than 100. Input y to repeat : ')
d='y'
if d=='y' :
thread_3()
def thread_4():
value_total = a*50/100+b*30/100+c*20/100
这是我的表达式在程序列表中的定义
^{pr2}$
最后,我运行这个程序:
只要我输入的数字是好的,但在最后程序显示的错误代码是那样的:Traceback (most recent call last): File "ganjil-genap.py", line 71, in
thread_4() File "ganjil-genap.py", line 36, in thread_4
value_total = a*50/100+b*30/100+c*20/100 NameError: global name 'a' is not defined
谁能告诉我我做错了什么吗?在
提前谢谢。在