from time import clock import sys def quadratic(): InFile=open('in6_1.txt','r') OutFile=open('out_1_6_1.txt','w') start=clock() Totalmul=0 Totaladd=0 a,b,c=InFile.readline().split(",") a=int(a) b=int(b) c=int(c) ## START mula=2*a Totalmul+=1 value=((b*b)-(2*mula*c)) Totalmul+=3 if value > 0 : ## 2 real roots value=value**0.5 Root1= ( -b + value )/mula Root2= ( -b - value )/mula Totaladd+=1 elif value == 0 : ## 1 real root Root1= -b / mula Root2="" else: ##value < 0 :no real roots, but 2 imaginary roots Root1= imaginary(-b / mula ,(-value)**0.5/mula) Root2=imaginary(-b / mula, -(-value)**0.5/mula) Totalmul+=2 Totaladd+=1 ##FINISH OutFile.write(str(Root1)+","+str(Root2)) OutFile.write("\nTotal Excution Time : "+str(clock()-start)) OutFile.write("\nTotal Multiplications are : "+str(Totalmul)) OutFile.write("\nTotal Addition is : "+str(Totaladd)) memUsed = sys.getsizeof(InFile) + sys.getsizeof(OutFile)+ sys.getsizeof(start)+ sys.getsizeof(a)+ sys.getsizeof(b)+ sys.getsizeof(c) + sys.getsizeof(Totalmul)+ sys.getsizeof(Totaladd)+ sys.getsizeof(mula)+ sys.getsizeof(value)+ sys.getsizeof(Root1)+ sys.getsizeof(Root2) OutFile.write("\nMemory used : "+str(memUsed)+" Bytes") InFile.close() OutFile.close() print "Check Your Output File : out_1_sec6_1.txt is Generated" InFile.close() OutFile.close() quadratic()