Python
# Program to check triangle validity and type
a = float(input("Enter first side: "))
b = float(input("Enter second side: "))
c = float(input("Enter third side: "))
if a <= 0 or b <= 0 or c <= 0:
print("Sides must be positive.")
elif a + b <= c or a + c <= b or b + c <= a:
print("Not a valid triangle.")
else:
if a == b == c:
print("Equilateral triangle")
elif a == b or a == c or b == c:
print("Isosceles triangle")
else:
print("Scalene triangle")Output
Enter first side: 3 Enter second side: 4 Enter third side: 5 Scalene triangle
First we apply the triangle inequality to check validity. Then we compare side lengths to classify as equilateral, isosceles, or scalene.