Coding with Python
Pythagorean Triples
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.
Part 1: Print this page for myself to have the task sequence...
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 |
Groups of 3 on Vertical Boards
Write down these first three terms, then extend the pattern by writing the next 3 terms…
Stage | Side a | Pattern | Side b | Pattern | Side c | Pattern |
0 | | | | | | |
1 | | | | |||
2 | | | | |||
3 | | | | |||
4 | | | | |||
5 | | | | |||
6 | | | |
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
Coding
How would you write code that checks if 3 numbers are a Pythagorean Triple?
Coding
Sign in to Replit.com
Click the link in Google Classroom.
https://replit.com/@LauraKingston/Pythagorean-Theorem#main.py
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. |
Same Program on Scratch