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()
I am fairly new to Python, and I'm playing with writing functions and returning variables, I'm a little confused on how to correct the code. I am writing a quadratic solver program, but I need to use the discriminant and a,b,c values in "the rest" function. (which does the rest of the equation.) I'm kind of confused on how to return the values and use them in another function. Thanks!