top of page

Python Program to Check Types of Triangle Given Sides


side1 = float(input("Enter the first side: "))
side2 = float(input("Enter the second side: "))
side3 = float(input("Enter the third side: "))

if side1 == side2 == side3:
    print('Equilateral Triangle')
elif side1 == side2 or side2 == side3 or side1 == side3:
    if side1**2 == side2**2 + side3**2 or side2**2 == side1**2 + side3**2 or side3**2 == side1**2 + side2**2:
        print('Right Isosceles Triangle') 
    else:
        print('Isosceles Triangle')
elif side1 != side2 != side3:
    if side1**2 == side2**2 + side3**2 or side2**2 == side1**2 + side3**2 or side3**2 == side1**2 + side2**2:
        print('Right Scalene Triangle') 
    else:
        print('Scalene Triangle')



Recent Posts

See All
Sorting Algorithms in Python

1. Selection sort Method 1 def selectionSort(array): n = len(array) for i in range(n): # Initially, assume the first element of the...

 
 
 
Search Algorithms in Python

1. Binary search def binary_search(data, target, low, high): if low > high: return False else: mid = (low+high)//2 if target ==...

 
 
 

Comments


bottom of page