# Program to check congruency of two triangles in Python

In this tutorial, we are going to check the congruency of two triangles. We are going to check SSS, SAS, and AAA. The similarity of the triangles is proved based on those criteria.

We have to check different conditions based on the theorem. Check them in the code below.

## Example

Live Demo

def side_side_side(sides_one, sides_two):
# sorting same pace
sides_one.sort()
sides_two.sort()
# checking the conditions
if sides_one / sides_two == sides_one / sides_two \
and sides_one / sides_two == sides_one / sides_two \
and sides_one / sides_two == sides_one / sides_two:
return True
return False
def side_angle_side(sides_one, sides_two, angles_one, angles_two):
# sorting same pace
sides_one.sort()
sides_one.sort()
angles_one.sort()
angles_one.sort()
# checking conding 1
if sides_one / sides_two == sides_one / sides_two:
if angles_one == angles_two:
return True
# checking conding 2
if sides_one / sides_two == sides_one / sides_two:
if angles_one == angles_two:
return True
# checking conding 3
if sides_one / sides_two == sides_one / sides_two:
if angles_one == angles_two:
return True
# return False if any of the above conditions are not satisfied
return False
def angle_angle_angle(angles_one, angles_two):
# sorting same pace
angles_one.sort()
angles_two.sort()
# checking the conditions
if angles_one == angles_two \
or angles_one == angles_two \
or angles_one == angles_two:
return True
return False
if __name__ == '__main__':
# initialzing the sides
sides_one = [2.0, 3.0, 3.0]
sides_two = [4.0, 6.0, 6.0]
# initialzing the angles
angles_one = [80.0, 60.0, 40.0]
angles_two = [40.0, 60.0, 80.0]
# checking the printing the respective property
print("Triangles are similar by:", end=' ')
if side_side_side(sides_one, sides_two):
print("SSS", end=' ')
if side_angle_side(sides_one, sides_two, angles_one, angles_two):
print("SAS", end=' ')
if angle_angle_angle(angles_one, angles_two):
print("AAA", end='')

## Output

If you run the above code, then you will get the following result.

Triangles are similar by: SSS SAS AAA

## Conclusion

If you have any queries regarding the tutorial, mention them in the comment section.