Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt as normalny
- from cmath import sqrt as zespolony
- a: int = 5
- b: int = 9
- c: int = 1
- def rownaniekwadratowe(a, b, c):
- delta = (b**2)-4*(a*c)
- print(delta)
- if delta > 0:
- return rzeczywiste(a, b, delta)
- else:
- if delta < 0:
- return zespolone(a, b, delta)
- else:
- return jednorozwiazanie(a, b)
- def rzeczywiste (a, b, delta) :
- delta = normalny(delta)
- x1 = (-b-delta)/(2*a)
- x2 = (-b+delta)/(2*a)
- print("pierwsiastki rzeczywiste :")
- return ( x1 , x2 )
- def jednorozwiazanie ( a, b):
- x1 = (-b)/(2*a)
- print("pierwiastek rzeczywisty : ")
- return ( x1 )
- def zespolone(a,b,delta) :
- delta = complex(delta, 0)
- delta = zespolony(delta)
- x1 = (-b - delta) / (2 * a)
- x2 = (-b + delta) / (2 * a)
- print("Pierwiastki zespolone: ")
- return(x1,x2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement