cs/practical-file/outputs/question_16_output.txt
2025-06-24 02:37:47 +05:30

26 lines
734 B
Plaintext

Question 16:
Write a Python program to accept three sides and check whether they form a valid triangle.
Answer:
def main(sides: tuple[int, int, int]) -> None:
a, b, c = sides
if a + b > c and a + c > b and b + c > a:
print(f"The sides {sides} form a valid triangle.")
else:
print(f"The sides {sides} do not form a valid triangle.")
if __name__ == '__main__':
main((3, 4, 5))
main((1, 2, 3))
main((5, 12, 13))
main((7, 10, 5))
main((1, 1, 2))
Output:
The sides (3, 4, 5) form a valid triangle.
The sides (1, 2, 3) do not form a valid triangle.
The sides (5, 12, 13) form a valid triangle.
The sides (7, 10, 5) form a valid triangle.
The sides (1, 1, 2) do not form a valid triangle.