Write the following two programs using Python Language.
Q1. Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is an equilateral triangle.
def is_equilateral(side1, side2, side3):
"""Determines if a triangle is equilateral based on its side lengths."""
return side1 == side2 == side3
# Get the lengths of the triangle's sides from the user
side1 = float(input("Enter the length of side 1: "))
side2 = float(input("Enter the length of side 2: "))
side3 = float(input("Enter the length of side 3: "))
# Check if the triangle is equilateral
if is_equilateral(side1, side2, side3):
print("The triangle is equilateral.")
else:
print("The triangle is not equilateral.")
Explanation:
is_equilateral
function:
True
if all three sides are equal, indicating an equilateral triangle.False
otherwise.Input:
input()
.float()
.Check for equilateral triangle:
if
statement to check the result of the is_equilateral
function.