Boundary Value Analysis : Nature of Roots of a Quadratic equation | BVA for nature of roots of a quadratic equation ; If a = 0 , D / 2 a will yield exception Hence it is not a valid Quadratic Equation ; If D > 0 , it will be Real Roots ; If D == 0 , it will be Equal Roots ; If D < 0 , it will be Imaginary Roots ; Function to check for all testcases ; Driver Code
def nature_of_roots ( a , b , c ) : NEW_LINE INDENT if ( a == 0 ) : NEW_LINE INDENT print ( " Not ▁ a ▁ Quadratic ▁ Equation " ) ; NEW_LINE return ; NEW_LINE DEDENT D = b * b - 4 * a * c ; NEW_LINE if ( D > 0 ) : NEW_LINE INDENT print ( " Real ▁ Roots " ) ; NEW_LINE DEDENT elif ( D == 0 ) : NEW_LINE INDENT print ( " Equal ▁ Roots " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " Imaginary ▁ Roots " ) ; NEW_LINE DEDENT DEDENT def checkForAllTestCase ( ) : NEW_LINE INDENT print ( " Testcase TABSYMBOL a TABSYMBOL b TABSYMBOL c TABSYMBOL Actual ▁ Output " ) ; NEW_LINE print ( ) ; NEW_LINE a = b = c = 0 ; NEW_LINE testcase = 1 ; NEW_LINE while ( testcase <= 13 ) : NEW_LINE INDENT if ( testcase == 1 ) : NEW_LINE INDENT a = 0 ; NEW_LINE b = 50 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 2 ) : NEW_LINE INDENT a = 1 ; NEW_LINE b = 50 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 3 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 50 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 4 ) : NEW_LINE INDENT a = 99 ; NEW_LINE b = 50 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 5 ) : NEW_LINE INDENT a = 100 ; NEW_LINE b = 50 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 6 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 0 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 7 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 1 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 8 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 99 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 9 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 100 ; NEW_LINE c = 50 ; NEW_LINE DEDENT elif ( testcase == 10 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 50 ; NEW_LINE c = 0 ; NEW_LINE DEDENT elif ( testcase == 11 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 50 ; NEW_LINE c = 1 ; NEW_LINE DEDENT elif ( testcase == 12 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 50 ; NEW_LINE c = 99 ; NEW_LINE DEDENT elif ( testcase == 13 ) : NEW_LINE INDENT a = 50 ; NEW_LINE b = 50 ; NEW_LINE c = 100 ; NEW_LINE DEDENT print ( " TABSYMBOL " , testcase , " TABSYMBOL " , a , " TABSYMBOL " , b , " TABSYMBOL " , c , " TABSYMBOL " , end = " " ) ; NEW_LINE nature_of_roots ( a , b , c ) ; NEW_LINE print ( ) ; NEW_LINE testcase += 1 ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT checkForAllTestCase ( ) ; NEW_LINE DEDENT