write a program to enter three sides of triangle and check whether the triangle is possible or not. if possible the display whether an equilateral is an iso scenes or scaline triangle other wise display a message .triangle is not possible
Answers
Answer:
s1 = int(input("First Side:"))
s2 = int(input("Second Side:"))
s3 = int(input("Third Side:"))
if s1 + s2 < s3 or s1 + s3 < s2 or s2 + s3 < s1:
print("Such Triangle Not possible")
else:
if s1 == s2 == s3:
print("Given side are of equilateral triangle")
elif s1 == s2 or s2 == s3 or s1 == s3:
print("Given side are of isosceles triangle")
else:
print("Given side are of scalene triangle")
Explanation:
def is_triangle(x, y, z):
if (x + y <= z) or (x + z <= y) or (y + z <= x):
return 0
return 1
def triangle_type(x, y, z):
if x == y == z:
return "Equilateral"
if x == y or y == z or z == x:
return "Isosceles"
return "Scalene"
x, y, z = [int(n) for n in input("enter x y z: ").split()]
if is_triangle(x, y, z):
print(f"{triangle_type(x, y, z)} triangle.")
else:
print("Triangle is not possible.")