我是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
这我的表达式 def 到程序列表中
if p==1:
            thread_1()
            thread_2()
            thread_3()
            thread_4()
最后,我运行这个程序:只要我输入数字是好的,但最后程序显示错误代码如下:
Traceback (most recent call last):   File "ganjil-genap.py", line 71, in <module>
    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
谁能让我知道我做错了什么?
提前致谢。