Rename function_3 to function_3.py
This commit is contained in:
11
python/function_3.py
Normal file
11
python/function_3.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# solves a quadratic equation in the form ax^2 + bx + c = 0
|
||||
def solve_quadratic(a, b, c):
|
||||
inside = b**2 - (4 * a * c)
|
||||
if (inside < 0):
|
||||
return None
|
||||
elif (inside == 0):
|
||||
return [-4/(2 * a)]
|
||||
else:
|
||||
return [(-b + inside**0.5) / (2 * a), (-b - inside**0.5) / (2 * a)]
|
||||
|
||||
print(solve_quadratic(1, 5, 6))
|
||||
Reference in New Issue
Block a user