Write a program that will read an arbitrary number of sets of triangle sides using only integer values.
You need to have functions for the following tasks:
Sample run:
Provide three side lengths – 0 0 0 to terminate.
3
5
4
3 5 4 Triangle possible: Scalene and Right.
def checkTypeOfTriangle(a,b,c):
sqa = pow(a, 2)
sqb = pow(b, 2)
sqc = pow(c, 2)
if (sqa == sqa + sqb or
sqb == sqa + sqc or
sqc == sqa + sqb):
print("Right.",end="\n")
elif(sqa > sqc + sqb or
sqb > sqa + sqc or
sqc > sqa + sqb):
print("Obtuse.",end="\n")
else:
print("Acute.",end="\n")
def is_valid_triangle(a,b,c):
if a+b>=c and b+c>=a and c+a>=b:
return True
else:
return False
while(1):
a=int(input())
b=int(input())
c=int(input())
if(a==0 and b==0 and c==0):
break
if is_valid_triangle(a, b, c):
print( a,b,c ,'Triangle possible: ',end="")
else:
print(a,b,c, 'Triangle is Invalid.')
continue
if a == b == c:
print("Equilateral and ",end="")
elif a==b or b==c or c==a:
print("Isosceles and ",end="")
else:
print("Scalene and ",end="")
checkTypeOfTriangle(a, b, c)
Comments
Leave a comment