Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. a = float(input())
  2. b = float(input())
  3. c = float(input())
  4.  
  5. d = b ** 2 - 4 * a * c
  6.  
  7. if a == 0:
  8.     if b == 0:
  9.         if c == 0:
  10.             print('Any number')
  11.         else:
  12.             print('No solution')
  13.     else:
  14.         print('x =', -c / b) # Solve linear equation  bx + c = 0
  15. elif d > 0:
  16.     x1 = (-b + d ** 0.5) / (2 * a)
  17.     x2 = (-b - d ** 0.5) / (2 * a)
  18.     print('x1 =', x1, 'x2=', x2)
  19. elif d == 0:
  20.     print('x =', -b / (2 * a))
  21. else:
  22.     print('No solution')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement