Saturday 23 December 2017

Roots of Quadratic Equations using Python code


Roots of Quadratic Equations using Python code

ax2+bx+c=0
where x represents an unknown, and ab, and c represent known numbers such that a is not equal to 0. If a = 0, then the equation is linear, not quadratic.

cmath :- 


This module is always available. It provides access to mathematical functions for complex numbers. The functions in this module accept integers, floating-point numbers or complex numbers as arguments.

Root's of Q Equation




-------------------------------------Python Code-----------------------------------

import cmath
print 'input'
a=input('side 1')
b=input('side 2')
c=input('side 3')
inroot=b**2-(4*a*c)
sol1=(-b- cmath.sqrt(inroot))/(2*a)
sol2=(-b+ cmath.sqrt(inroot))/(2*a)

No comments:

Post a Comment

IT's Good