Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. from math import sqrt
  4. a, b, c = input("enter a, b, c: ").split()
  5.  
  6. if a == 0: a = 1
  7. else: a = int(a)
  8.  
  9. if b == 0: b = 1
  10. else: b = int(b)
  11.  
  12. if c == 0: c = 1
  13. else: c = int(c)
  14.  
  15. D = (b**2 - 4 * a * c)
  16. print("D:", D)
  17. if D > 0:
  18.     D = sqrt(D)
  19.     if not D.is_integer():
  20.        D = D
  21. else:
  22.     print("корней нет!")
  23.     exit(0)
  24.  
  25. print("sqrt(D):", D)
  26.  
  27. x1 = (-b - D) / (2 * a)
  28. x2 = (-b + D) / (2 * a)
  29. print("x1 = " + str(x1))
  30. print("x2 = " + str(x2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement