Pure Programmer
Blue Matrix


Cluster Map

Project: Pythagorean Theorem

The Pythagorean Theorem in geometry defines the relationship between the three sides of a right triangle. If the square of the longest side (the hypotenuse) is equal to the sum of the squares of the other two sides, then the triangle is a right triangle. If this relationship does not hold, then the triangle is not a right triangle.

Write a program that prompts the user for the length of the hypotenuse and the other two legs. Then determine if the triangle is a right trangle and then print that it is or isn't a right triangle.

See [[Pythagorean Theorem]]

Output
$ python3 PythagoreanTheorem.py Hypotenuse: 5 Leg #1: 4 Leg #2: 3 Triangle is a right triangle! $ python3 PythagoreanTheorem.py Hypotenuse: 5.1 Leg #1: 4.2 Leg #2: 3.3 Triangle is NOT a right triangle!

Solution