cs/Practical File/questions/question_16_output.txt
Neil Revin 780baf678e
chore: move question & output files
Move python question files to 'questions' directory
Move output files to 'outputs' directory
Copy output files to 'questions' for ease of viewing

Signed-off-by: Neil <neil@willofsteel.me>
2025-06-24 02:34:07 +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.