PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# equation of second degree:ax^2+bx+c=0
#below:a=ax^2,b=bx,c=c
#this program will calculate x for you :)
#just tap run(and an input will show)enter your numbers on 3 seperated lines
try:
a = ax2 = float(input())
b = bx = float(input())
c = c = float(input())
Delta = b**2-4*a*c
print("the form of second degree equation is : ax^2+bx+c")
print("your equation is",int(a),"x^2","+",int(b),"x","+",int(c),"=","0")
print("Delta=",Delta)
if Delta > 0:
from math import sqrt
x1 = (-b-sqrt(Delta))/(2*a)
print("x1 =",x1)
x2 = (-b+sqrt(Delta))/(2*a)
sum = -b/a
product = c/a
print("or")
print("x2 =",x2)
print("their sum is:",sum)
print("their product is:",product)
elif Delta == 0:
x1 = x2 = -b/2*a
print("x1 = x2 =",x1)
elif Delta < 0 :
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run