Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def F(a, b, c):
- d = b**2 - 4 * a * c;
- import math
- if d > 0:
- x1 = (-b + math.sqrt(d)) / (2 * a)
- x2 = (-b - math.sqrt(d)) / (2 * a)
- return(x1,x2)
- if d == 0:
- x = -b / (2 * a)
- return(x)
- if d<0:
- x1 = complex(-b/2, ((-d)**(1/2))/ 2)
- x2 = complex(-b/2, -((-d)**(1/2))/ 2)
- return(x1,x2)
- print(F(5,-9,-2))
- print(F(20,5,40))
- print(F(2,4,2))
Add Comment
Please, Sign In to add comment