This article has been dead for over six months: Start a new discussion instead

Reputation Points: 0 [?]

Q&As Helped to Solve: 0 [?]

Skill Endorsements: 0 [?]

•Unverified Member

Reputation Points: 0 [?]

Q&As Helped to Solve: 0 [?]

Skill Endorsements: 0 [?]

•Unverified Member

0

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:

```
def get_coefficients():
a = float(raw_input('a = '))
b = float(raw_input('b = '))
c = float(raw_input('c = '))
return (a,b,c)
def calculate_solutions(a, b, c):
if a == 0:
return None
else:
under_radical = b*b - 4*a*c
if under_radical < 0:
return None
else:
root = math.sqrt(under_radical)
solution1 = (-b + root) / a * 2
solution2 = (-b - root) / a * 2
return (solution1, solution2)
def print_solutions(solutions):
if solutions == None:
print 'no solution'
else:
print solutions[0]
print solutions[1]
```

i then made the actual program:

```
import quadratic
print 'hello quadratics'
a,b,c = quadratic.get_coefficients()
solutions = quadratic.calculate_solutions(a, b, c)
quadratic.print_solutions(solutions)
```

again, i was only wondering if there were other ways of doing this, thank you.

Reputation Points: 7 [?]

Q&As Helped to Solve: 1 [?]

Skill Endorsements: 4 [?]

•Unverified Member

You

This article has been dead for over six months: Start a new discussion instead

Tags Related to this Article