Python Practice › If-Else Programs › Program 35
Equilateral triangle check
Write a Python program to check whether a triangle is equilateral (all three sides equal).
Input
(10, 10, 10), (10, 15, 10)
Output
(10, 10, 10) is equilateral (10, 15, 10) is not equilateral
Approach
- Compare all three sides with a chained
==.
Solution
for a, b, c in [(10, 10, 10), (10, 15, 10)]: if a == b == c: print((a, b, c), "is equilateral") else: print((a, b, c), "is not equilateral")Output
(10, 10, 10) is equilateral (10, 15, 10) is not equilateral
Line by line
Line 2
a == b == c means a == b and b == c.
Learn the concept
New to this topic? Read the lesson, then come back.