hello, i was only wondering if there were other ways of making a quadratic formula calculator in python.
i recently made one my self by making a module i named quadratic which is shown below:
a = float(raw_input('a = '))
b = float(raw_input('b = '))
c = float(raw_input('c = '))
def calculate_solutions(a, b, c):
if a == 0:
under_radical = b*b - 4*a*c
if under_radical < 0:
root = math.sqrt(under_radical)
solution1 = (-b + root) / a * 2
solution2 = (-b - root) / a * 2
return (solution1, solution2)
if solutions == None:
print 'no solution'
i then made the actual program:
print 'hello quadratics'
a,b,c = quadratic.get_coefficients()
solutions = quadratic.calculate_solutions(a, b, c)
again, i was only wondering if there were other ways of doing this, thank you.
This may help. http://www.daniweb.com/software-development/python/code/217087/pythagorean-theorem-calculator
Maybe more this http://www.daniweb.com/software-development/python/code/356952/pep8-quadratic-equations-solver
You can make your module give real and complex solutions.