Python从各种函数返回变量

Sha*_*mar 2 python variables return function

from __future__ import division
import math

def main():
    the_discriminant = discrim(1,0,-4)
    print the_discriminant
    the_rest(discrim,b,a)

def discrim(a,b,c):
    discriminant = math.sqrt(math.pow(b,2)-4*a*c)
    return discriminant, b,a

def the_rest(discrim,b,a):
    x = ((-b + discriminant) / 2*a)
    y = ((-b - discriminant) / 2*a)
    print x,y

if __name__ == '__main__':
    main()
Run Code Online (Sandbox Code Playgroud)

我是Python的新手,我正在编写函数和返回变量,我对如何纠正代码有点困惑.我正在编写一个二次求解器程序,但我需要在"其余"函数中使用判别式和a,b,c值.(这完成了其余的等式.)我对如何返回值并在另一个函数中使用它感到困惑.谢谢!

jam*_*lak 7

the_rest(*the_discriminant)
Run Code Online (Sandbox Code Playgroud)

或(我更喜欢这种方法):

d, b, a = discrim(1, 0, -4)
the_rest(d, b, a)
Run Code Online (Sandbox Code Playgroud)