kilolilo

Untitled

Nov 1st, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. from math import sqrt
  2. a=open("test.txt") 
  3. def kv(BLIST):
  4.     a=BLIST[0]
  5.     b=BLIST[1]
  6.     c=BLIST[2]
  7.     d=b*b-4*a*c
  8.     if (d<0):
  9.         print "d<0"
  10.         return
  11.     x1=(-b+sqrt(d))/(2*a)
  12.     x2=(-b-sqrt(d))/(2*a)
  13.     if (d==0):
  14.         x1=-b/(2*a)
  15.         print x1
  16.         return
  17.     print  x1,x2
  18. for line in a:
  19.     mas=line.split()
  20.     for j in range (0,3,1):
  21.         mas[j] = float(mas[j])
  22.     kv(mas)
Add Comment
Please, Sign In to add comment