Skip to main content
Back to module
Math for Tech & STEM · Geometry and Trigonometry

Right triangles and Pythagoras

Reading26mLesson 2 of 3 in this module

What you'll learn

  • Solve right triangles with the Pythagorean theorem
  • Find a missing leg by subtracting squares
  • Check a corner is square with the 3-4-5 rule
  • Find the distance between two points using coordinate differences

Use the Pythagorean theorem to find missing sides, distances and diagonals in right triangles.

Why this matters

Right angles are everywhere people build things: walls meet floors, screens are rectangles, city blocks form grids. Whenever you need a diagonal or a straight-line distance across a right angle, the Pythagorean theorem gives it. Carpenters use it to check that corners are square, electricians use it to estimate conduit runs, game developers use it to measure distance between characters, and data scientists use its big brother, Euclidean distance.

The core idea

In a right triangle (one angle exactly 90°):

  • The two sides that form the right angle are the legs, a and b.
  • The longest side, opposite the right angle, is the hypotenuse, c.

The Pythagorean theorem says:

a² + b² = c²

The squares on the two legs add up to the square on the hypotenuse. It works only for right triangles.

Finding the hypotenuse

c = √(a² + b²)

Legs 3 and 4: c = √(9 + 16) = √25 = 5.

Finding a missing leg

Rearrange: a = √(c² − b²)

A 13 m ladder reaches 12 m up a wall. How far is its foot from the wall? a = √(169 − 144) = √25 = 5 m.

Notice you subtract when finding a leg. If you add, the "leg" comes out longer than the hypotenuse, which is impossible and a useful warning sign.

Worked example 1: screen size

A monitor is 60 cm wide and 34 cm tall. Screens are sold by diagonal:

c = √(60² + 34²) = √(3600 + 1156) = √4756 ≈ 68.96 cm, about 27.1 inches (÷ 2.54).

Worked example 2: is the corner square?

The 3-4-5 rule: measure 3 units along one wall and 4 along the other. If the diagonal between the marks is exactly 5, the corner is 90°. This works because the converse of the theorem is also true: if a² + b² = c², the angle is a right angle. Builders often scale it up to 6-8-10 or 9-12-15 for better accuracy.

Common Pythagorean triples (whole-number right triangles): 3-4-5, 5-12-13, 8-15-17, 7-24-25, and any multiple of these.

Worked example 3: distance between two points

The distance between points (x₁, y₁) and (x₂, y₂) is a hypotenuse whose legs are the x and y differences:

d = √((x₂ − x₁)² + (y₂ − y₁)²)

From (1, 2) to (7, 10): d = √(6² + 8²) = √100 = 10.

In three dimensions, add a third squared term: d = √(Δx² + Δy² + Δz²). The diagonal of a 3 × 4 × 12 box is √(9 + 16 + 144) = √169 = 13.

In code

Python's math module has the square root, and even a ready-made hypotenuse function:

Python
import math

print(math.sqrt(3**2 + 4**2))    # 5.0
print(math.hypot(60, 34))        # about 68.96
print(math.dist((1, 2), (7, 10)))  # 10.0

Writing the formula yourself once is the best way to understand what hypot and dist are doing.

Common mistakes

  • Using it on a triangle without a right angle. Use the law of cosines instead (you will meet it later).
  • Labelling the wrong side as c. The hypotenuse is always opposite the right angle and is always the longest.
  • Adding instead of subtracting when finding a leg.
  • Forgetting the square root: a² + b² gives c², not c.
  • Writing √(a² + b²) as a + b. √(9 + 16) is 5, not 7.

Quick recap

  • For a right triangle: a² + b² = c², with c the hypotenuse.
  • Hypotenuse: c = √(a² + b²). Leg: a = √(c² − b²).
  • If the sides satisfy the equation, the triangle has a right angle (3-4-5 check).
  • Distance between points is Pythagoras on the coordinate differences.

Try it

In the Do tab, write the hypotenuse formula. A missing-leg function and a distance function are already written, and they depend on yours.

Key terms (5)

right triangle
A triangle with one angle of exactly 90°.
hypotenuse
The longest side of a right triangle, opposite the right angle.
legs
The two sides of a right triangle that form the right angle.
Pythagorean theorem
In a right triangle, the squares of the two legs add up to the square of the hypotenuse: a² + b² = c².
Pythagorean triples
Whole-number sides of a right triangle, such as 3-4-5 and 5-12-13.

Recap

  • In a right triangle a² + b² = c², where c is the hypotenuse
  • Hypotenuse c = √(a² + b²); a missing leg a = √(c² − b²)
  • If the sides satisfy the equation, the angle is a right angle (the 3-4-5 check)
  • The distance between two points is Pythagoras on their coordinate differences
Also in this lesson: