Triangle type

Assume the side lengths are positive and form a valid triangle. Invalid triangles are outside this task.

Write a function that takes three integers as input representing the sides of a triangle and returns "Equilateral" if all sides are equal, "Isosceles" if two sides are equal, and "Scalene" if all sides are different.

Complete Listing 1. Save the completed code as check_triangle_type.py and run it to check the supplied assertions.

Listing 1: Starter function and checks for check_triangle_type.
def check_triangle_type(side1: int, side2: int, side3: int) -> str:
    raise NotImplementedError("Replace this line with your code.")


# All three sides equal
got = check_triangle_type(5, 5, 5)
assert got == "Equilateral", f"5, 5, 5: expected 'Equilateral', got {got!r}"

# The equal pair comes first
got = check_triangle_type(4, 4, 3)
assert got == "Isosceles", f"4, 4, 3: expected 'Isosceles', got {got!r}"

# The equal pair is split, which a check of neighbours only will miss
got = check_triangle_type(4, 3, 4)
assert got == "Isosceles", f"4, 3, 4: expected 'Isosceles', got {got!r}"

# The equal pair comes last
got = check_triangle_type(3, 4, 4)
assert got == "Isosceles", f"3, 4, 4: expected 'Isosceles', got {got!r}"

# No two sides equal
got = check_triangle_type(3, 4, 5)
assert got == "Scalene", f"3, 4, 5: expected 'Scalene', got {got!r}"

# Your case: which three sides are most likely to break it?
# got = check_triangle_type(___, ___, ___)
# assert got == "___", f"___: expected '___', got {got!r}"
  • assert condition checks a Boolean condition. A true condition produces no output; a false condition raises AssertionError. For example, assert 2 + 3 == 5 passes.