Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- a, b, c = map(float, input().split(' '))
- if not a:
- if not b:
- print(-1)
- else:
- print(format(-c/b, '.3f'))
- else:
- d = b**2 - 4*a*c
- if d > 0:
- x1 = (-b + math.sqrt(d))/(2*a)
- x2 = (-b - math.sqrt(d))/(2*a)
- if x1 > x2:
- print(format(x1, '.3f'), format(x2, '.3f'))
- else:
- print(format(x2, '.3f'), format(x1, '.3f'))
- elif not d:
- print(format(-b/(2*a), '.3f'))
- else:
- print(-1)
- Traceback (most recent call last):
- File "595bd828-ce3d-4d8b-9055-47517a8a18c0", line 3, in <module>
- a, b, c = map(float, input().split(' '))
- ValueError: could not convert string to float:
- -10000<=a, b, c <=10000
- Они могут быть любого типа (не только целые)
- разделены пробелами
Add Comment
Please, Sign In to add comment