Python Program to find the roots of the quadratic equation with its value

Hello everyone, welcome to nkcoderz.com. In this article we will going to discuss about Python Program to find the roots of the quadratic equation with its value.

To find the roots of a quadratic equation in Python, you can use the following formula:

x = (-b + sqrt(b**2 - 4*a*c)) / (2*a)
y = (-b - sqrt(b**2 - 4*a*c)) / (2*a)

Here, “x” and “y” are the roots of the equation, and “a”, “b”, and “c” are the coefficients of the equation. The coefficients can be entered as input to the program. The “sqrt” function is used to calculate the square root of a value.

Area of Circle Program In Python

Here’s an example of how you could use this formula to find the roots of a quadratic equation:

Python Program to find the roots of the quadratic equation with its value

import math

def find_roots(a, b, c):
  x = (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)
  y = (-b - math.sqrt(b**2 - 4*a*c)) / (2*a)
  return x, y

a = 1
b = 5
c = 6
roots = find_roots(a, b, c)
print(roots)

This code would output the roots of the quadratic equation “ax^2 + bx + c = 0” with coefficients “a”, “b”, and “c” equal to 1, 5, and 6, respectively.

Output

(-2.0, -3.0)

Conclusion

If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment