Równanie Kwadratowe - Python

This commit is contained in:
Mateusz Słodkowicz 2024-11-17 23:19:10 +01:00
parent f3d91b23b2
commit b0addfdb67
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
import math;
a = float(input("Podaj a: "))
b = float(input("Podaj b: "))
c = float(input("Podaj c: "))
if(a==0):
x=c/b
print("To jest rownanie liniowe\n", x)
else:
Delta=b*b-4*a*c
if (Delta < 0):
print("Brak rozwiazan")
elif (Delta > 0):
x1=(-b - math.sqrt(Delta))/(2*a)
x2=(-b + math.sqrt(Delta))/(2*a)
print('Dwa pierwiastki\n', x1,'\n', x2)
else:
x=b/(2*a)
print('Jeden pierwiastek\n',x);