Pythagorean Theorem! 📐
Bookie0 (5660)


How are ya'll doing? Hope everyone is chilling EsPeCiAlLy WiTh tHiS sPeCiAl InAuGaRaTiOn AnD sPeCiAl LeAvInG oF tHiS sPeCiAl OrAnGe PeRsOn ThAt I wOn'T mEnTiOn HeRe!!!

Welcome to a tutorial on the Pythagorean Theorem!!! 🎉

You've probably already heard of Mr. Pythagoras and his famous Theorem, and with this tutorial we'll be learning about him, looking at what his Theorem is about, some fun facts about it, and finally a small program to calculate the hypothenuse and/or determine if a triangle is right-angled (and a few other things)!

Let's start!! xD

Full contents:

  • 1) Pythagoras
    - Life
    - Famous Works

  • 2) The Pythagorean Theorem
    - What it Is
    - Equation
    - How it Works

  • 3) Fun Facts
    - Theorem Well Known Before
    - Syntesthesia
    - Death
    - 4 Lives
    - Numbers

  • 4) The Program
    - How to Use
    - Brief Explanation of Code (And a bit of Math)

  • 5) Links
    - Sources
    - Helpful Links

  • 6) Closing

1) Pythagoras


Behold the man himself:

Pythagoras was an Ancient Greek Philosopher born in Samos, Greece in about ~570 BCE. He died in Metapontum, Italy, in about ~490 BCE, at the age of around 75 years old. Pythagoras spent most of his early life on the island of Samos, but when he was about 40, he emigrated to a city in Italy, Cortona. This is where most of his philosophical activity occurred.

Pythagoras was well brought up and well educated; he could play the lyre and recite poems as well as Homer. He was also interested in philosopy, mathematics, astronomy, and music. Pythagoras was influenced by some men like Pherekydes (a thinker), Thales (a mathematician), and Anaximander (a philospher). He was often called the first "True Mathematician"!

In about ~518 BCE, Pythagoras founded a philosophical and religious school in Crotona (a Greek colony in Italy). This was where he and some followers lived and worked. They worked together on discoveries and theories.

Famous Works

  • Numerical System

Pythagoras started the idea of a numerical system, which is the beginning of mathematics. In a nutshell, the numerical system is:

"A numeral system is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. "

(From here)

  • Numbers with "personalities"

According to him, numbers were vital and made up the world.

Each number had its own personality - masculine or feminine, perfect or incomplete, beautiful or ugly. This feeling modern mathematics has deliberately eliminated, but we still find overtones of it in fiction and poetry. Ten was the very best number: it contained in itself the first four integers - one, two, three, and four [1 + 2 + 3 + 4 = 10] - and these written in dot notation formed a perfect triangle.

  • Pythagoras' Philosopy

Pythagoras and his followers hypothesized that everything in the universe could be clarified, or explained, with numbers. For example, today, we use numbers for calculating chances of precipitation, how fast a vehicle is going, wind speeds, etc.

  • Music Theory

This one is kinda an unusual one; it's about intervals in music, and I found it pretty interesting:

Pythagoras is also credited with the discovery that the intervals between harmonious musical notes always have whole number ratios. For instance, playing half a length of a guitar string gives the same note as the open string, but an octave higher; a third of a length gives a different but harmonious note; etc.

Non-whole number ratios, on the other hand, tend to give dissonant sounds. In this way, Pythagoras described the first four overtones which create the common intervals which have become the primary building blocks of musical harmony: the octave (1:1), the perfect fifth (3:2), the perfect fourth (4:3) and the major third (5:4). The oldest way of tuning the 12-note chromatic scale is known as Pythagorean tuning, and it is based on a stack of perfect fifths, each tuned in the ratio 3:2.

To represent it better:


2) The Pythagorean Theorem

What it Is

You all most likely know about the Pythagorean Theorem, and we all encounter it at school in math class.

So here's a little crash course if you havn't been listening!

Basically, let's say we have a rectangle triangle ABC with a 90˚ right angle on B (not real lengths):

Let's say side AB = 3 and side BC = 4. What does side AC equal?

That's when we'll use this formula (when I write ^2 it means squared or 'to the power of 2'):


AC^2 = AB^2 + BC^2

Meaning side AC squared equals the sum of sides AB squared and BC squared. So using the measures from the previous example:

AC^2 = AB^2 + BC^2
AC^2 = 3^2 + 4^2
AC^2 = 9 + 16
AC^2 = 25

There, now we have AC^2 = 25! Now to just find side AC, we can square root it:

AC^2 = 25
AC = √25
AC = 5

Voilà, we've found out that AC, the hypothenuse of triangle ABC equals 5.

How it Works

Now why and how does this interesting equation work? To visualize it better, imagine if you put squares with length the side of each side of the triangle, like this:

To calculate the area of a square, it's side^2, so with the formula that squares each side of the triangle, we now have squares. So the area of the red square (on the hypothenuse) is equal to the sum of the areas of the two other squares.

3) Fun Facts

Some cool facts about Pythagoras and the Pythagoras Theorem:

  • Apparently, this theorem was well known by Indian, Chinese, Babylonian, and Greek mathematicians well before Pythagoras lived.

  • Some historians think Pythagoras had a medical condition called synesthesia. People affected with synesthesia makes them able to see music, "hear" colors, and connect certain smells with people's name. This is perhaps how he thought of his Music Theory.

  • How exactly Pythagoras died is still a mystery. Pythagoras' followers went into conflic with supporters of democracy and other topcis, and Pythagoras' group's houses where they met were bruned down. Maybe Pythagoras was killed in those burnings, or maybe he escaped to Metapontum ad eventually died there.

  • Pythagoras declared to have lived 4 lives. Yes, 4. He also once said he remember those lives.

  • The Pythagoreans believed that the number 1 was symbol of unity and was the origin of all things. 2 meant female, 3 meant male. The number 4 represented justice. 10 was the most perfect number as 1 + 2 + 3 + 4 = 10.

4) The Program

How To Use

So when you run the code, you'll find yourself in the main menu. You'll have different modes to choose from; the first mode where you can find the length of the hypothenuse in a right-angled triangle, the second mode where you can check if a triangle is right-angled, and the last mode where you can check your history and find out your previous calculations.

For the mode 1 (by the way, I'm using getch() so you don't have to press [enter], unlike input()), you'll have to enter the lengths of the triangle other than the hypothenuse. Like the program says:

Where side C is the hypothenuse, and side A and B are the other sides.

After entering those values, you can also choose how many digits after the decimal point (5 max). Next, the program shall calculate for you the length of the hypothenuse and detail the steps.

Then when you get back to the menu and try out the second mode to check if a triangle is right-angled, this time you'll have to enter the 3 lengths of the triangle. It'll check if it's right-angled, again detailing the steps, and will give the final verdict.

Finally, with the history, you'll have all your recent calculations, for both mode 1 and mode 2. You can also clear your history if you want.

Brief Explanation of Code (And a bit of Math)

So first, some imports like math (for square rooting), os (to clear the console screen), getch, and time. Next, some variables holding ANSI escape codes for the colors. After that, you'll see the dict history_operation that holds the calculation as item and the result as value. There's also the variable incrementer for outputting the contents of the history (with a for loop). Finally, there's the digits_after_decimal variable that's initally 2.

Next we have the 2 functions for the 2 modes. Those functions have float(input())s for getting the numbers from the users. Then, the program calculates all the values using ** and math.sqrt and gives the result (with nice colors); either the length of the hypothenuse or wether the triangle is right-angled or not. At the end of each functions, it saves the results in the dict for the history.

Finally, with the last function history_functions(), it clears the screen using os.system('clear') and with a for loop outputs each item and value of the history_operation dict (if the dict isn't empty.)

In the while True loop, it displays the menu choices, and with some conditionals calls the functions based on what the user wants to do. That's about all, a pretty straightforward program.

Read the comments I inserted into the code for more! ;)

5) Links


Helpful Links

For more about the Pythagorean Theorem and about Pythagoras, you can visit the links above and here are a few more:

6) Closing

Well, that's about all. I hope you've learnt something cool and new about Pythagoras and the Pythagorean Theorem. This can help you in math class, so go amaze your classmates and teachers!

  • Also, you know, try to learn the real way of how to calculate the hypothenuse; this program was just for 'illustrating purposes', you probably shouldn't use or rely on this during a test lol. But have fun with it anyways! :)

And also this amazing video, I have no idea this works but it's super amazing. Check it out!

Until we meet again! 👋

PS: In case you missed it, run the repl as there is a program.

PPS: Extend the console to the maximum so you can see the most!! :)
You are viewing a single comment. View All
CyberHacker101 (109)

I seriously dont understand why this post just has 6 cycles only man

XanthusPettitt (4)

@CyberHacker101 sorry im new but what are "cycles"

Bookie0 (5660)

@XanthusPettitt useless internet reputation points. You get 1 cycle when someone upvotes your post/comment, 5 cycles when they select your answer as correct (only on ask board though).