Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def x2(a, b, c):
- D = b ** 2 - 4 * a * c
- for_user_abc = 'a = ' + str(a) + '; ' + 'b = ' + str(b) + ' ;' + 'c = ' + str(c)
- for_user_D = str(b) + '^2' + ' - ' + '4 * ' + str(a) + ' * ' + str(c) + ' = ' + str(b ** 2) + ' - ' + str(4 * a * c) + ' = ' + str(D)
- if D < 0:
- print(for_user_abc)
- print(for_user_D)
- print('D < 0')
- return 'Нет корней!'
- elif D == 0:
- x = -b / 2 * a
- print(for_user_abc)
- print(for_user_D)
- print('D = 0')
- return x
- else:
- x_1 = (-b + np.sqrt(D)) / (2 * a)
- x_2 = (-b - np.sqrt(D)) / (2 * a)
- print(for_user_abc)
- print(for_user_D)
- return x_1, x_2
- x2(14,-5,-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement