##### Pythagorean Theorem! 📐

# Hey!

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 Works2) The Pythagorean Theorem

- What it Is

- Equation

- How it Works3) Fun Facts

- Theorem Well Known Before

- Syntesthesia

- Death

- 4 Lives

- Numbers4) The Program

- How to Use

- Brief Explanation of Code (And a bit of Math)5) Links

- Sources

- Helpful Links6) Closing

## 1) Pythagoras

### Life

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`

'):

### Equation

`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

### Sources

- Stanford Enclocypedia
- Brain Pickings
- Math Open Reference
- Ancient History Lists
- Story of Mathematics
- Math is Fun
- Facts.net
- Britannica

### 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!! :)

Repl.It has turned into a math class....... @Bookie0 How is this related to programming.....

@OldWizard209 well, there *is* a program..

And math is coding/programming in a way. I did this tutorial after the Fibonacci that teaches recursion in programming.

@Bookie0 there is? I just saw math lol

run the program! :)@XanthusPettitt

You know what, I really love math and I already know this, but you put your time and effort into this so u. rilly deserve an updooot @Bookie0

@OldWizard209 lol thanks!

"updoot" sounds like saying upvote but you burp in the vote part @OldWizard209

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

haha thanks! @CyberHacker101

@CyberHacker101 sorry im new but what are "cycles"

@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).

@Bookie0 ok thank you!

@CyberHacker101 idk man this concept is p simple

I know that but there is so many words. I DONT LIKE MANY WORDS!!!!!!!!!!!!! @TsunamiOrSumth

@CyberHacker101 radical a^2+b^2 or radical c^2-b^2

idk man wat ur talking about @CodeLongAndPros

haha i remember learning this stuff

@BobTheTomatoPie ahaha lol guess it just *sticks* with you! xD

You forgot to mention his obsession with beans @Bookie0

Pythagoras and Beans - Vi Hart (Not a rickroll)

Orange...Person...I can't hold it in anymore...

**BWAHAHAHAHAHAHAHAHA**

@Bookie0 this is rly cool! ~~even tho i hate math like almost everyone else~~

*gives updoot*

@CodingRedpanda lol thanks, glad this helped! :D

@Bookie0 lol np

@Kookiez thanks!!

lol

This is to much please get this removed off replit before more peoples brain explodes.

@Rainbowryan lmfao thanks!

@Bookie0 Im not kidding my small middle school brain is not smart enought for this

I, speaking on the behalf of the council of 2-year-olds, are not pleased with this. We do not know what your...putting a number to the *power of 2* is and we do not know what the '+' sign means. You should have explained in further detail...BTW I know what all of these terms mean, just the council told me to say this to you.

P.S. the one word that caught my attention

@Whippingdot I, replying on behalf of over 13 year olds (because 2 year olds aren't allowed on repl.it according to the ToS), understand completely your opinion. However, you can tell your.. *2-year-olds* that for example *x to the power of 2* is *x times x*. So if *x = 5*, *x to the power of 2*, or rather *x^2* = *5^2* = 25.

And the '+' sign means *addition* meaning that 1 + 1 = 11. That is understandably harder to understand.

Oh ok thx

Thank you for helping me and the council. They are very pleased. They will give you many choopies in return. Be prepared for the scene in harry potter movie/book one replaced from mail to choopies in ** your** home. Have a good day @Bookie0

@Whippingdot ..Ok same to you and the council

~ogey bogey~

did it work? @CyberHacker101

@CyberHacker101if you want strike-throuhg, try `~~text~~`

= ~~text~~

~~ogey bogey~~@Bookie0

Nice tutorial! ;)

thank you!! :D @JBYT27

Np! :D @Bookie0

LOL! I made a similar thing a while ago in C#, but it had no colors and was a lot lazier, with no decimal point asking or explanation. It just took inputs and spit out the answer.

https://repl.it/@CoolGuy27/pythagorean-theorem-in-C

@CoolGuy27 oh lol!

speak poems

Idk if its just me, or do i feel like anyone can *speak* poems if they have vocal chords? I would say something like *recite* poems meaning that he memorized them or wrote them...

just a suggestion tho

@elipie hum yes, good suggestion I'll add it! thanks!

:D also

EsPeCiAlLy WiTh tHiS sPeCiAl InAuGaRaTiOn AnD sPeCiAl LeAvInG oF tHiS sPeCiAl OrAnGe PeRsOn ThAt I wOn'T mEnTiOn HeRe!!!

FINALLY I CAN CHILL WITHOUT BEING MAD AGAIN

(srry repl no politics im too happy)

@Bookie0 looool

@Bookie0 i don't make games or anythin i usually study alot of code from different languages cus im bored

@ArchieMullin alright.

hippity hopity this code is now my propert cntrl c + cntrl v go BRRRRRRRRRRRRRRRRRR

@ArchieMullin okay, make sure to give some credit though lol!

Woooohooooooo the old orange man left the white cheesecake house.

@CyberHacker101 yum cheesecake

also what do you mean by "spam"? @Kookiez

@CyberHacker101 where?

lol as you said " I wont be as active this month due to spam" cant ya just turn da ringer off or somethin @Kookiez

@CyberHacker101 oh right because at least 25% of the new posts in share are spam, and i also have school too

lol ooof @Kookiez

Just btw, it should be AB with a line across the top, not A*B

@CodeLongAndPros wait sry, where?

@CodeLongAndPros oh, by AB I meant like segment AB, not A times B

How would I add the line across the top?

@Bookie0 You’ve made Repl.it history with presenting us with a completely new subject, Math!!! Lol

@DarthVader29 haha lol, this is kinda a sequel to a few other math tutorials I've made (Monty Hall Problem and Fibonacci, if you're interested xD)

Amazing!

@amasad wow, thank you!!! :D