(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Program to find the roots of a quadratic equation - TecGlance

Header Ads

Program to find the roots of a quadratic equation



==================  ROOT OF QUADRATIC EQUATION =====================



 print "Quaratic Equqtion must be in form of a(x*x)+bx=c=0"

 a=input("Enter 'a' part of Quadratic Equation :")

 b=input("Enter 'b' part of Quadratic Equation :")

 c=input("Enter 'c' part of Quadratic Equation :")

 e=b**2-4*a*c

 if e<0:

     print "No real root exist"

 else:

     import math

     d=math.sqrt(e)

     root1=(-b+d)/(2*a)

     root2=(-b-d)/(2*a)

     print "Root of Qudratic Equation is ",root1 ," and ", root2



========================== OUTPUT =============================



 Quaratic Equqtion must be in form of a(x*x)+bx=c=0

 Enter 'a' part of Quadratic Equation :1

 Enter 'b' part of Quadratic Equation :-3

 Enter 'c' part of Quadratic Equation :-10

 Root of Qudratic Equation is  5.0  and  -2.0



========================== OUTPUT =============================



 Quaratic Equqtion must be in form of a(x*x)+bx=c=0

 Enter 'a' part of Quadratic Equation :2

 Enter 'b' part of Quadratic Equation :2

 Enter 'c' part of Quadratic Equation :2

 No real root exist



===================================================================

No comments

Powered by Blogger.