Quadratic equation
Daniel Sidorowicz
dsi1289 at gmail.com
Fri Mar 13 16:06:44 EDT 2009
Hello I need some hello I need some help with a programingproject, I'm
fairly new to programming so I do find it slightly confusing.
Here is my code for my main function which
passes my variable from a text file,
however when i run it I get the error code:
import math
import quadroot
def main():
print "\n--------------------------------------------\n"
print "Daniel Sidorowicz \n", "325 \n", "MCS 260, Spring 2009 \n",
"mp1id325"
print "For instructions open file named README"
print "Enter control-C to quit"
infile = open("abc.txt",'r')
L = infile.readlines()
S = L.split()
print S
infile.close()
outfile = open("output.txt",'a')
eq = "ax^2.0 + bx + c = 0\n"
for line in L:
coef= a,b,c = (float(S[0]),float(S[1]),float(S[2]))
print coef
print "\n--------------------------------------\n"
d = b**2.0 - 4.0*a*c
if a != 0:
if d == 0.0 :
outfile.write(eq)
outfile.write(str(quadroot.root1(a,b,c,d)))
elif d > 0.0 :
outfile.write(eq)
outfile.write(str(quadroot.root2(a,b,c,d)))
elif d < 0.0 :
outfile.write(eq)
outfile.write(str(quadroot.root3(a,b,c,d)))
else :
"Never get here!"
elif a == 0 :
if b != 0:
outfile.write(eq)
outfile.write(str(quadroot.root5(b,c)))
else:
if c == 0:
outfile.write(eq)
outfile.write(str(quadroot.root6()))
else:
outfile.write(eq)
outfile.write(str(quadroot.root4(a,b,c,d)))
else:
"Never get here!"
outfile.close()
main()
AttributeError: 'list' object has no attribute 'split'
Can someone please explain/clarify this issue to me thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090313/7bc40f95/attachment.html>
More information about the Python-list
mailing list