Advertisement
STANAANDREY

ex3 lab1 LSD

Sep 30th, 2022 (edited)
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. from math import sqrt
  2.  
  3. def eq_gr_2(a, b, c):
  4.     delta = b ** 2 - 4 * a * c
  5.     if (delta < 0):
  6.         return "There is no solution!"
  7.  
  8.     if (delta == 0):
  9.         return (-b + sqrt(delta)) / (2 * a)
  10.  
  11.     x1 = (-b + sqrt(delta)) / (2 * a)
  12.     x2 = (-b - sqrt(delta)) / (2 * a)
  13.     return x1, x2
  14.  
  15. if __name__ == "__main__":
  16.     a = int(input("a="))
  17.     b = int(input("b="))
  18.     c = int(input("c="))
  19.  
  20.     print("answer:", eq_gr_2(a, b, c))
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement