Lesson goal: The Pythagorean Theorem Calculator

Previous: Solving Quadratic Equations | Home | Next: Fermat's Last Theorem

In this past lesson, you learned how to use the square root, or math.sqrt to compute the hypotenuse of a right triangle using the Pythagorean Theorem, which is $c^2=a^2+b^2$.

In this lesson, we'll use the if statement and develop this more into a complete Pythagorean Theorem calculator.

This code will ask you for then length of all 3 sides of a right triangle. For the side you don't know, type in a question mark (?). A series of if statements can be used to figure out which side to calculate for you.

Now you try. Fix each if statement with a true/false question to see if the variable computed within its body is the one for which the user typed a ?.

Type your code here:


See your results here: