SHARE
TWEET

Untitled

a guest Jan 24th, 2020 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def discriminant(a, b, c):
  2.     return (b ** 2) + (-4 * a * c)
  3.  
  4.  
  5. def larger_root(p, q):
  6.     a = (-p - (discriminant(1, p, q) ** 0.5)) / 2
  7.     if a > (-p + (discriminant(1, p, q) ** 0.5)) / 2:
  8.         return a
  9.     else:
  10.         return (-p + (discriminant(1, p, q) ** 0.5)) / 2
  11.  
  12.  
  13. def smaller_root(p, q):
  14.     a = (-p - (discriminant(1, p, q) ** 0.5)) / 2
  15.     if a < (-p + (discriminant(1, p, q) ** 0.5)) / 2:
  16.         return a
  17.     else:
  18.         return (-p + (discriminant(1, p, q) ** 0.5)) / 2
  19.  
  20.  
  21. def main():
  22.     p = float(input())
  23.     q = float(input())
  24.     print(discriminant(1, p, q))
  25.     print(smaller_root(p, q), larger_root(p, q))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top