- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
def side_side_side(sides_one, sides_two): # sorting same pace sides_one.sort() sides_two.sort() # checking the conditions if sides_one[0] / sides_two[0] == sides_one[1] / sides_two[1] \ and sides_one[1] / sides_two[1] == sides_one[2] / sides_two[2] \ and sides_one[2] / sides_two[2] == sides_one[0] / sides_two[0]: 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[0] / sides_two[0] == sides_one[1] / sides_two[1]: if angles_one[0] == angles_two[0]: return True # checking conding 2 if sides_one[1] / sides_two[1] == sides_one[2] / sides_two[2]: if angles_one[1] == angles_two[1]: return True # checking conding 3 if sides_one[2] / sides_two[2] == sides_one[0] / sides_two[0]: if angles_one[2] == angles_two[2]: 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[0] == angles_two[0] \ or angles_one[1] == angles_two[1] \ or angles_one[2] == angles_two[2]: 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.
- Related Articles
- Program to check two rectangular overlaps or not in Python
- What is congruency?
- Program to check a number is power of two or not in Python
- Python program to check if binary representation of two numbers are anagram.
- Python Program to check if two given matrices are identical
- Python program to check whether two lists are circularly identical
- Python Program to Check If Two Numbers are Amicable Numbers
- Program to check two parts of a string are palindrome or not in Python
- Program to check whether two sentences are similar or not in Python
- Program to check whether leaves sequences are same of two leaves or not in python
- C++ Program to Check Multiplicability of Two Matrices
- Program to check whether two string arrays are equivalent or not in Python
- Program to check sum of two numbers is up to k from sorted List or not in Python
- Python program to check if two lists have at least one common element
- 8085 Program to check for two out of five code

Advertisements