def triangle_type(a, b, c): if a == b and b == c: return "Equilateral triangle" # Равносторонний треугольник elif a == b or b == c or a == c: return "Isosceles triangle" # Равнобедренный треугольник else: return "Scalene triangle" # Разносторонний треугольник a = float(input("Enter the length of side A: ")) b = float(input("Enter the length of side B: ")) c = float(input("Enter the length of side C: ")) triangle = triangle_type(a, b, c) print("Triangle type:", triangle)
Пример использования:
Enter the length of side A: 5 Enter the length of side B: 5 Enter the length of side C: 5 Triangle type: Equilateral triangle Enter the length of side A: 3 Enter the length of side B: 4 Enter the length of side C: 5 Triangle type: Scalene triangle
if a == b and b == c:
return "Equilateral triangle" # Равносторонний треугольник
elif a == b or b == c or a == c:
return "Isosceles triangle" # Равнобедренный треугольник
else:
return "Scalene triangle" # Разносторонний треугольник
a = float(input("Enter the length of side A: "))
b = float(input("Enter the length of side B: "))
c = float(input("Enter the length of side C: "))
triangle = triangle_type(a, b, c)
print("Triangle type:", triangle)
Пример использования:
Enter the length of side A: 5Enter the length of side B: 5
Enter the length of side C: 5
Triangle type: Equilateral triangle
Enter the length of side A: 3
Enter the length of side B: 4
Enter the length of side C: 5
Triangle type: Scalene triangle