Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions quadraticequationgenerator
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import cmath # Import the cmath module for complex number support.

def solve_quadratic(a, b, c):
# Calculate the discriminant using the quadratic formula.
discriminant = cmath.sqrt(b**2 - 4*a*c)

# Calculate the two roots of the quadratic equation.
root1 = (-b + discriminant) / (2*a) # The first root.
root2 = (-b - discriminant) / (2*a) # The second root.

# Return the roots as a tuple.
return root1, root2