Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. import time
  2. import math
  3.  
  4. print("\t\t\t\tThe 2° Equations Solver")
  5. a=int(input("enter the a for X² (please put the + or - ): "))
  6. b=int(input("enter the b for X (please put the + or - ): "))
  7. c=int(input("enter the c (please put the + or - ): "))
  8.  
  9. print("your equation is :")
  10. time.sleep(1)
  11. print(a,".x²",b,".x",c)
  12.  
  13. y_n=input(" Is it true? [yes / no] : ")
  14. if y_n == "yes":
  15.     delta = b * b - 4 * a * c
  16.     if delta > 0:
  17.         print("the equation has two solution :")
  18.         j = math.sqrt(delta)
  19.         time.sleep(1)
  20.         x1 = (-b - j) / (2 * a)
  21.         x2 = (-b + j) / (2 * a)
  22.         print(x1)
  23.         print(x2)
  24.     elif delta == 0:
  25.         print("the equation has one solution :")
  26.         time.sleep(1)
  27.         print(-b / (2 * a))
  28.     elif delta < 0:
  29.         print("the equation has no solution.")
  30.     else:
  31.         print("error")
  32. elif y_n=="no":
  33.     print("sorry! try again or enter 'enter' to quit")
  34.     time.sleep(2)
  35. else:
  36.     print("error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement