Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a=int(input("Enter a: "))
- b=int(input("Enter b: "))
- c=int(input("Enter c: "))
- d = b**2-4*a*c
- x1 = (-b + (d**0.5))/2*a
- x2 = (-b - (d**0.5))/2*a
- #for complex
- c1 = (-b/2*a)
- c2 = ((-d)**0.5)/(2*a)
- #complex----- output a+ib and a-ib formated by (c1+ic2),(c1-ic2)
- if(d >= 0):
- print("Roots are : ",x1,"and",x2)
- else:
- print("Roots are : (",c1,"+ i",c2,") (",c1,"- i",c2,")")
Add Comment
Please, Sign In to add comment