Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import math
- print("\t\t\t\tThe 2° Equations Solver")
- a=int(input("enter the a for X² (please put the + or - ): "))
- b=int(input("enter the b for X (please put the + or - ): "))
- c=int(input("enter the c (please put the + or - ): "))
- print("your equation is :")
- time.sleep(1)
- print(a,".x²",b,".x",c)
- y_n=input(" Is it true? [yes / no] : ")
- if y_n == "yes":
- delta = b * b - 4 * a * c
- if delta > 0:
- print("the equation has two solution :")
- j = math.sqrt(delta)
- time.sleep(1)
- x1 = (-b - j) / (2 * a)
- x2 = (-b + j) / (2 * a)
- print(x1)
- print(x2)
- elif delta == 0:
- print("the equation has one solution :")
- time.sleep(1)
- print(-b / (2 * a))
- elif delta < 0:
- print("the equation has no solution.")
- else:
- print("error")
- elif y_n=="no":
- print("sorry! try again or enter 'enter' to quit")
- time.sleep(2)
- else:
- print("error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement