Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. def x2(a, b, c):
  2. D = b ** 2 - 4 * a * c
  3. for_user_abc = 'a = ' + str(a) + '; ' + 'b = ' + str(b) + ' ;' + 'c = ' + str(c)
  4. for_user_D = str(b) + '^2' + ' - ' + '4 * ' + str(a) + ' * ' + str(c) + ' = ' + str(b ** 2) + ' - ' + str(4 * a * c) + ' = ' + str(D)
  5. if D < 0:
  6. print(for_user_abc)
  7. print(for_user_D)
  8. print('D < 0')
  9. return 'Нет корней!'
  10. elif D == 0:
  11. x = -b / 2 * a
  12. print(for_user_abc)
  13. print(for_user_D)
  14. print('D = 0')
  15. return x
  16. else:
  17. x_1 = (-b + np.sqrt(D)) / (2 * a)
  18. x_2 = (-b - np.sqrt(D)) / (2 * a)
  19. print(for_user_abc)
  20. print(for_user_D)
  21. return x_1, x_2
  22.  
  23. x2(14,-5,-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement