Skip to content
← Back to Community
Pythagorean Theorem! 📐
Profile icon
Bookie0

Hey!

How are y'all doing? Hope everyone is chilling and doing well!

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
    1. The Pythagorean Theorem
    • What it Is
    • Equation
    • How it Works
    1. Fun Facts
    • Theorem Well Known Before
    • Syntesthesia
    • Death
    • 4 Lives
    • Numbers
    1. The Program
    • How to Use
    • Brief Explanation of Code (And a bit of Math)
    1. Links
    • Sources
    • Helpful Links
    1. Closing

1) Pythagoras

Life

Behold the man himself:

pythagoras

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:

pythagoras_music

Source

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

Screen Shot 2021-01-20 at 6.07.13 PM

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

Screen Shot 2021-01-20 at 6.07.25 PM

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:

Screen Shot 2021-01-12 at 10.44.07 AM

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.

Screen Shot 2021-01-12 at 11.15.46 AM


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.

Screen Shot 2021-01-20 at 11.32.52 AM

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.

Screen Shot 2021-01-20 at 11.34.05 AM

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! ;)


Sources

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!! :)
Voters
Profile icon
VXZELL12345
Profile icon
mylifeiscrap
Profile icon
SilvermoonCat
Profile icon
Error104114
Profile icon
AlbieHarrison
Profile icon
maxina
Profile icon
Shomy1
Profile icon
boldblade004
Profile icon
Reeperto
Profile icon
CoolGuy27
Comments
hotnewtop
Profile icon
amasad

Amazing!

Profile icon
Bookie0

@amasad
wow, thank you!!! :D

Profile icon
Bookie0

Also:

hehe funny joke I found

Screen Shot 2020-10-06 at 9.18.02 AM

Profile icon
JBloves27

Hahahah XD

@Bookie0

Profile icon
Bookie0
Profile icon
JBloves27

Looooool

@Bookie0

Profile icon
OldWizard209

Repl.It has turned into a math class.......

@Bookie0
How is this related to programming.....

Profile icon
Bookie0

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

Profile icon
XanthusPettitt

@Bookie0
there is? I just saw math lol

Profile icon
Bookie0

run the program! :)@XanthusPettitt

Profile icon
OldWizard209

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

Profile icon
Bookie0

@OldWizard209
lol thanks!

Profile icon
CyberDaDev

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

@OldWizard209

Profile icon
LegendaryWolf

bruh we need to lern math to code,

Profile icon
OldWizard209

yap, and that is why, most people quit programming even before they write "Hello World"

@LegendaryWolf

Profile icon
Bookie0
Profile icon
FlaminHotValdez

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

BWAHAHAHAHAHAHAHAHA

Profile icon
Bookie0
Profile icon
CyberDaDev

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

Profile icon
Bookie0

haha thanks!

@CyberHacker101

Profile icon
XanthusPettitt

@CyberHacker101
sorry im new but what are "cycles"

Profile icon
Bookie0

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

Profile icon
XanthusPettitt

@Bookie0
ok thank you!

Profile icon
Bookie0
Profile icon
CyberDaDev

My brain after reading this
Screenshot 2021-01-20 at 6.35.42 PM

Profile icon
TsunamiOrSumth

@CyberHacker101
idk man this concept is p simple

Profile icon
CyberDaDev

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

@TsunamiOrSumth

Profile icon
Bookie0
Profile icon
Bookie0
Profile icon
CodeLongAndPros

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

Profile icon
CyberDaDev
Profile icon
CyberDaDev

idk man wat ur talking about

@CodeLongAndPros

Profile icon
LegendaryWolf

are u highschooler

Profile icon
CyberDaDev

Uh ya talkin to me?

@LegendaryWolf

Profile icon
CyberDaDev

Yo bro if ya wanna talk to someone you have to put the
@( Persons username) to tag or ping them

@LegendaryWolf

Profile icon
LegendaryWolf

yes I am

Profile icon
LegendaryWolf

ik that, but forgot to...

Profile icon
CyberDaDev

nah bro im in middle school

@LegendaryWolf

Profile icon
LegendaryWolf

mee too

@CyberHacker101
. Grade? Sorry of im disturbing you

Profile icon
BobTheTomatoPie

haha i remember learning this stuff

Profile icon
Bookie0

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

Profile icon
[deleted]

You forgot to mention his obsession with beans

@Bookie0

Pythagoras and Beans - Vi Hart (Not a rickroll)

Profile icon
Bookie0
Profile icon
[deleted]
Profile icon
glitchish

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

Profile icon
Bookie0

@CodingRedpanda
lol thanks, glad this helped! :D

Profile icon
glitchish

@Bookie0
lol np

Profile icon
Kookiez

good job!

also:

image

he looks quite depressed

Profile icon
Bookie0

@Kookiez
thanks!!
lol

Profile icon
RainBowLion1

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

Profile icon
Bookie0

@Rainbowryan
lmfao thanks!

Profile icon
RainBowLion1

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

Profile icon
Bookie0
Profile icon
CyberDaDev

OI! we aint dat stoopid

@RainBowLion1

Profile icon
Whippingdot

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

image
You should correct it, it is supposed to be, CORTANA

Profile icon
Bookie0

@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

Profile icon
Whippingdot

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

Profile icon
Bookie0

@Whippingdot
..Ok same to you and the council

Profile icon
Whippingdot

😁😁😁😁

@Bookie0

Profile icon
CyberDaDev

ogey bogey

Profile icon
CyberDaDev

did it work?

@CyberHacker101

Profile icon
Bookie0

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

Profile icon
CyberDaDev

ogey bogey

@Bookie0

Profile icon
CyberDaDev
Profile icon
Bookie0
Profile icon
CyberDaDev

Ahhh i was young and stupid back then...

@Bookie0

Profile icon
JBloves27

Nice tutorial! ;)

Profile icon
Bookie0

thank you!! :D

@JBYT27

Profile icon
JBloves27

Np! :D

@Bookie0

Profile icon
mylifeiscrap

Cool!

Profile icon
Bookie0

okay I think that's enouguh :)

@mylifeiscrap

Profile icon
mylifeiscrap

Okay I’ll stop

@Bookie0

Profile icon
Bookie0

aight thanks! :D

@mylifeiscrap

Profile icon
CyberDaDev

Ahhh it used to be 6 cycles now it is 44 cycles i still get pings from this bro

@Bookie0

Profile icon
LegendaryWolf

I'd do algebra, but there is a problm

Profile icon
AlbieHarrison

no

Profile icon
Bookie0
Profile icon
CoolGuy27

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

Profile icon
Bookie0

@CoolGuy27
oh lol!

Profile icon
elipie

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

Profile icon
Bookie0

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

Profile icon
elipie

: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

Profile icon
Bookie0

@elipie
lool

Profile icon
elipie

@Bookie0
looool

Profile icon
ArchieMullin

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

Profile icon
Bookie0

@ArchieMullin
alright.

Profile icon
ArchieMullin

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

Profile icon
Bookie0

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

Profile icon
CyberDaDev

Woooohooooooo the old orange man left the white cheesecake house.

Profile icon
Kookiez

@CyberHacker101
yum cheesecake

Profile icon
CyberDaDev
Profile icon
CyberDaDev

also what do you mean by "spam"?

@Kookiez

Profile icon
Kookiez
Profile icon
CyberDaDev

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

@Kookiez

Profile icon
Kookiez

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

Profile icon
CyberDaDev

lol ooof

@Kookiez

Profile icon
CodeLongAndPros

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

Profile icon
Bookie0

@CodeLongAndPros
wait sry, where?

Profile icon
CodeLongAndPros

@Bookie0

A31AAB91-F916-4B27-9789-59B7357B16FD

Profile icon
Bookie0

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

How would I add the line across the top?

Profile icon
LuckyOreos

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

Profile icon
Bookie0

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