Guest User

Untitled

a guest
Jan 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import math
  2.  
  3. a, b, c = map(float, input().split(' '))
  4.  
  5. if not a:
  6. if not b:
  7. print(-1)
  8. else:
  9. print(format(-c/b, '.3f'))
  10. else:
  11. d = b**2 - 4*a*c
  12.  
  13. if d > 0:
  14. x1 = (-b + math.sqrt(d))/(2*a)
  15. x2 = (-b - math.sqrt(d))/(2*a)
  16.  
  17. if x1 > x2:
  18. print(format(x1, '.3f'), format(x2, '.3f'))
  19. else:
  20. print(format(x2, '.3f'), format(x1, '.3f'))
  21. elif not d:
  22. print(format(-b/(2*a), '.3f'))
  23. else:
  24. print(-1)
  25.  
  26. Traceback (most recent call last):
  27. File "595bd828-ce3d-4d8b-9055-47517a8a18c0", line 3, in <module>
  28. a, b, c = map(float, input().split(' '))
  29. ValueError: could not convert string to float:
  30.  
  31. -10000<=a, b, c <=10000
  32. Они могут быть любого типа (не только целые)
  33. разделены пробелами
Add Comment
Please, Sign In to add comment