Dremendo Tag Line

Input angles and check equilateral, isosceles, or scalene triangle in Python

if elif - Question 8

In this question, we will see how to input 3 angles of a triangle and check whether it is an equilateral, isosceles or scalene triangle in Python programming using the if elif statement. To know more about if elif statement click on the if elif statement lesson.

Q8) Write a program in Python to input 3 angles of a triangle and check whether it is an equilateral, isosceles or scalene triangle.

An equilateral triangle is one whose all angles are equal and the sum of all the angles is 180. An isosceles triangle is one whose any two angles are equal and the sum of all the angles is 180. A scalene triangle is one whose none of the angles are equal but sum of all the angles is 180.

Program

print('Enter 3 angles of a triangle')
a=int(input())
b=int(input())
c=int(input())

if a+b+c==180:
    if a==b and b==c and c==a:
        print('Equilateral traingle')
    elif a==b or b==c or c==a:
        print('Isosceles traingle')
    else:
        print('Scalen triangle')
else:
    print('Invalid input')

Output

Enter 3 angles of a triangle
45
90
45
Isosceles traingle           
video-poster