Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- print("ax^2+bx+c=0")
- a=int(input("Nhập a:"))
- b=int(input("Nhập b:"))
- c=int(input("Nhập c:"))
- D=b*b-4*a*c
- if D<0:
- print("Phương Trình Vô nghiệm")
- elif D==0:
- x1=x2=(-b/2*a)
- print("X1=X2={0}".format(x1))
- elif D>0:
- x1=(-b+math.sqrt(D))/2*a
- x2=(-b-math.sqrt(D))/2*a
- print("X1={0} , X2={1}".format(x1,x2))
- elif a+b+c==0:
- x1=1
- x2=c/a
- print("X1=1, X2={0}".format(X2))
- elif a-b+c==0:
- x1=-1
- x2=-c/a
- print("X1=-1 , X2={0}".format(x1))
- else:
- print("Sai cú pháp")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement