Python code to solve quadratic equation , Easy beginner project

0

 


Hello coders, welcome to the new blog post this is the first blog of the beginner projects series . This will be something really simple to think, the algorithm is really simple based on what you studied in your maths class when you were in 6th or 7th standard.

This is simply based on the Shridhar acharya method of finding roots of simple quadratic equations also know as the second-degree equation.

So here is the source code 

# Solve the quadratic equation ax**2 + bx + c = 0

# import complex math module
import cmath

a = 16
b = -40
c = 9

# calculate the discriminant
d = (b**2- (4*a*c)

# find two solutions
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)

print('The solution are {0} and {1}'.format(sol1,sol2))


This is a really simple project for beginners. If you have any query comment down below. 

Post a Comment

0 Comments
Post a Comment (0)
To Top