kilolilo

Untitled

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