Check whether triangle is valid or not if three points are given | Function to check if three points make a triangle ; Calculation the area of triangle . We have skipped multiplication with 0.5 to avoid floating point computations ; Condition to check if area is not equal to 0 ; Driver code
def checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) : NEW_LINE INDENT a = ( x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ) NEW_LINE if a == 0 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT ( x1 , x2 , x3 ) = ( 1 , 2 , 3 ) NEW_LINE ( y1 , y2 , y3 ) = ( 1 , 2 , 3 ) NEW_LINE checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) NEW_LINE DEDENT