INTRO PYTHON - Prac Test
INTRO PYTHON - Prac Test
Write Python code to address the following task as fully and accurately as possible.
Read ALL the instructions below BEFORE beginning!
The hypotenuse of a right-angle triangle abc is the longest side (c) and is opposite the right angle.
(See diagrams below)
c
b
a
You are required to write a modular program in python that:
1. displays the program title “HYPOTENUSE CALCULATOR BY: your full Name” in the Python console with a
blank line above and below, where your full name are your actual real names.
2. displays a short message explaining the purpose of the program to the user.
3. requests 2 numbers from the user, sideA and sideB, representing the length of sides a and b.
(Only Positive numbers less than or equal to 100 are acceptable otherwise display an error message and
allow up to 3 tries to input valid lengths for the sides, before the program quits.)
4. outputs the result of calculating the hypotenuse of a right triangle with side lengths a and b, using the
following sentence
“The hypotenuse of a right triangle with Side A of length ______ and Side B of length ______ is _______”
The actual values input for a and b and the calculated value of the hypotenuse c should replace the
underscores in the sentence.
5. under all circumstances, the program ends by displaying the message
“PROGRAM ENDED. THANKYOU.” With a blank line above it.
Page 1 of 1