Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- imp=open('import.txt','r')
- out=open('outport.txt','w')
- line= imp.readline()
- spline= line.split()
- q=float(spline[0])
- r=float(spline[1])
- t=float(spline[2])
- def quadr(a,b,c):
- d=0
- d=b*b-4*a*c
- if d>0:
- x1=(-b+sqrt(d))/(2*a)
- x2=(-b-sqrt(d))/(2*a)
- return (x1,x2)
- elif d==0:
- x1=-b/(2*a)
- return(x1,)
- else:
- return()
- solution=quadr(q,r,t)
- outline="error"
- print type(solution)
- if len(solution) == 0:
- outline="no solution"
- print outline
- out.write(outline)
- elif len(solution) == 1:
- outline="1 solution"
- x1=solution[0]
- #outline=' x1=%.5f\n' % (x1,)
- print x1
- print outline
- out.write(outline)
- else :
- outline="2 solution"
- x1=solution[0]
- x2=solution[1]
- print x1,x2
- print outline
- out.write(outline)
- imp.close()
- out.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement