1 of 10

Coding with Python

Pythagorean Triples

2 of 10

Lesson Description

Day 1: Learn about the Sum of Squares

Learn to use the a2+b2=c2 formula to find the hypotenuse or legs.

If you start with a 3-4-5 triangle, what happens if you double the sides, what happens if you triple them, etc.

Day 2:

Part 1: Alex Overwijk’s Task Sequence

Includes fractions, Pythagorean Theorem, linear and non-linear patterning. This task produces a whole bunch of Pythagorean Triples

Part 2: Simple Python Code that Checks for Pythagorean Triples

Discuss what Pythagorean Triples are.

Develop some pseudocode as a class for how you would write a program that checks for Pythagorean Triples.

Have students make an account on replit.com

Give them the link to the code, have them open it, run it and test it out with the lists of Pythagorean Triples that we developed.

Give them options for editing the code to change what it does.

3 of 10

Part 1: Print this page for myself to have the task sequence...

  1. Extend the pattern
  2. Turn them into improper fractions
  3. Now think of the two parts of the fraction as legs of a triangle and find the hypotenuse. Then put it in a table.
  4. Look at the table patterns. Figure out if each pattern is linear or non-linear. Find the equations for the ones that you are able to.
  5. Enter the tables in Desmos and do a quadratic regression to figure out the equation of b.
  6. What would the numbers be on the 43rd step?
  7. Verify that those numbers satisfy Pythagorean Theorem.

Stage

Side a

Pattern

Side b

Pattern

Side c

Pattern

0

1

3

4

5

2

5

12

13

3

7

24

25

4

9

40

41

5

11

60

61

6

13

y=2x+1

84

y=2x2+2x

85

y=2x2+2x+1

4 of 10

Groups of 3 on Vertical Boards

Write down these first three terms, then extend the pattern by writing the next 3 terms…

5 of 10

Stage

Side a

Pattern

Side b

Pattern

Side c

Pattern

0

1

2

3

4

5

6

6 of 10

Pythagorean Triples

The first known recorded Pythagorean Triples were found on a Babylonian clay tablet from about 1800 BCE

Pythagoras of Samos lived from 570 – 495 BCE

7 of 10

Coding

How would you write code that checks if 3 numbers are a Pythagorean Triple?

8 of 10

Coding

Sign in to Replit.com

Click the link in Google Classroom.

https://replit.com/@LauraKingston/Pythagorean-Theorem#main.py

9 of 10

Click “Fork” to make your own copy of the code.

Edit the code:

🔥

🔥🔥

🔥🔥🔥

Change the output statements. Like, instead of saying “Enter a number ” make it say something more than that.

Change the code so that it asks for the legs (a and b) and then calculates and outputs the hypotenuse.

Change the code so that it asks the user if they want to calculate the hypotenuse or one of the legs. Then take their input and two sides, calculate and output the missing side.

10 of 10

Same Program on Scratch