Run this on the command line using python
, takes the a
, b
and c
values of the quadratic as arguments:
python quad.py 1 1 0
The above would solve for:
x^2 + x = 0
and output:
-1.0±√1.0
___________
2.0
# coding=UTF-8 | |
import sys | |
import math | |
a = float(sys.argv[1]); | |
b = float(sys.argv[2]); | |
c = float(sys.argv[3]); | |
print str(-b)+"±√"+str(pow(b,2) - (4*a*c))+"\n___________\n"+str(2*a) |