Basic Music Theory in ~200 Lines of Python
As a primer for music theory, this post doesn&#x27;t teach much. It&#x27;s using Python to derive various sets of notes in scales and modes, which is already easily available via google search, and in a more learnable format than Python code.<p>The most basic aspect of Western music theory overlooked here is the relationship between tonic and dominant. If you know the &quot;home&quot; chord aka &quot;the I&quot; aka &quot;tonic&quot; is C major, the dominant will be G major, aka the V chord. Add just the F major chord, and you&#x27;ll know 1-4-5 in a &quot;basic&quot; key: C major. 1-4-5 is the simplest chord progression, you can play amazing grace, you are my sunshine, even The Beatles, you&#x27;ll be rocking with 1-4-5.<p>Next level, if you add in the minor 6 (a minor) and minor 2 (d minor), you realistically know 95% of the chords you&#x27;ll ever hear in C major pieces. And on the piano, this is ALL white notes, so even someone with zero musical knowledge can &quot;solo&quot; over your chords by just plunking any white notes while you play these chords (kids LOVE LOVE this btw, highly recommend trying with a kiddo).<p>I wouldn&#x27;t consider double-sharps and double-flats &quot;basic&quot; music theory. They really aren&#x27;t needed for beginners, since they&#x27;re relegated to keys like C# major where you&#x27;ll occasionally sharpen a note like E# (aka F) into E## (aka F#). I didn&#x27;t run into these until around 5 years into my piano training, playing Chopin&#x27;s F# major nocturne Op 15 No 2, there&#x27;s a bunch of double sharps in that piece.<p>In any case, don&#x27;t worry about double-flats and double-sharps or the precise notes of various modes and scales. Just learn pieces you enjoy, preferably with a mentor or teacher who can suggest improvements based on their trained ear.