...and at the end he shows you how to do the same thing with two lines of R.
It's very useful to code basic statistical algorithms yourself so you understand how they work, but for any serious analysis you'll get more reliable and performant results with a library.