From 5a6370b0be2e6a16f0f02015a517e0ec83b41401 Mon Sep 17 00:00:00 2001 From: Vinay Reddy Date: Sat, 7 Oct 2023 21:32:17 +0530 Subject: [PATCH] Create quadraticequationgenerator --- quadraticequationgenerator | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 quadraticequationgenerator diff --git a/quadraticequationgenerator b/quadraticequationgenerator new file mode 100644 index 0000000..10bcc52 --- /dev/null +++ b/quadraticequationgenerator @@ -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