Python – My Old Friend

I must admit that when I first started this self-taught career change towards my actual passion I was pretty lost on where to start it. All I really knew was that machine learning was super interesting and the neural networks side of it was even more interesting because I’ve always loved biomimicry. I had been learning new languages, APIs, and other software tools to automate the boring stuff in my Mechanical Engineering career for nearly a decade, so where should I start? Lucky for me, the first language I ever had the pleasure to learn and dive into was Python which also happens to be the most popular language used in machine learning. So I literally googled “Python Bootcamp” and the first result seemed like a good place to start:

This course was pretty good, especially for only $12. I really enjoyed being introduced to Jupyter Notebook which is a very hands-on interactive way to learn and play around with code that I’d definitely recommend to anyone wanting to learn. The pace of this course was also good because I could put the lectures on 1.5x speed which is a great perk when learning online compared to sitting in a lecture with a very slow-speaking professor; it’s nice to learn at your own pace even when it’s faster. I’d recommend this course to anyone wanting to get a decent introduction and overview of Python. I wouldn’t say you become a “hero” from it, however a lot of what you learn can certainly be applied to many areas in our digital lives so the course was worth it for me.

Personally, I did the bare minimum for the milestone assignments because I’ve basically done variations of them in C, C++, and C# over the years. I added these to my GitHub anyway and I’m sure that I’ll laugh at them some day in the future when I’m a far better programmer. That said, I applied (and still have been) what I learned in this course for some of my own personal uses. For example, just for fun I have an “oh sh*t, the world’s ending” external hard-drive which has an offline copy of Wikipedia (text only) on it and for the Final Capstone project of the course I wanted to find a way to easily add the best educational videos from the Crash Course YouTube channel onto it. Since these videos are also hosted on their website for download I used all that I learned in this course to find, download, and rename all the videos I wanted in one go. It uses the HTML parser Beautiful Soup to go through the links on the /downloads/ page and grabs the useful courses I wanted:

import requests
import bs4
import urllib.request
import os
#Change site for which set to DL
home_res = requests.get('')
home_soup = bs4.BeautifulSoup(home_res.text,"lxml") #convert to soup
all_courses ='.article-content p a')

link_start = ''
root_dl_loc = 'C://Users//rsgn6//Downloads//Crash Course//'
#courses I want via link endings as dictionary keys for a title
to_get = {'biology':'Crash Course - Biology', \
          'chemistry':'Crash Course - Chemistry', \
          'economics':'Crash Course - Economics',\
          'engineering': 'Crash Course - Engineering',\
          'busent': 'Crash Course - Entrepreneurship',\
          'euro': 'Crash Course - European History',\
          'ochem': 'Crash Course - Organic Chemistry',\
          'compsci': 'Crash Course - Computer Science',\
          'physics': 'Crash Course - Physics',\
          'psychology' : 'Crash Course - Psychology',\
          'stats' : 'Crash Course - Statistics',\
          'worldhistory' : 'Crash Course - World History',\
          'worldhistory2' : 'Crash Course - World History 2'}
for course in all_courses:
    course_link_name = course['href'].split(link_start)[-1] #split returns an array; -1 means last to get link ending
    if course_link_name in to_get.keys():
        folder_to_save_in = root_dl_loc + to_get[course_link_name]
        os.mkdir(folder_to_save_in) #make folder for course
        print(f'Created: {folder_to_save_in}')
        res = requests.get(link_start + course_link_name)
        soup = bs4.BeautifulSoup(res.text,"lxml")
        link_to_dl ='div ol li a') #list of <a href>
        episode_count = 1
        for links in link_to_dl:
            url_link = links['href'][17:] #17 and on is because of a pre-link to video structure
            #remove characters not allowed in filenames and add an Episode Number
            filename = 'Ep' + str(episode_count) + ' - ' + links.text.replace(':',' -').replace('?','').replace('/','-') + '.mp4'
            urllib.request.urlretrieve(url_link, f'{folder_to_save_in}//{filename}') #downoad the video and save the name as the text in the <a href>
            print(f'Downloaded: {filename}')
            episode_count += 1


I have also since utilized what I learned in this course to batch-compress videos using ffmpeg, fix filenames in a directory, and occasionally challenge myself to some coding problems to keep me up to speed. Overall, this was a decent spot to start my self-taught journey and I’m quite happy that Python is still the wonderful language I remember from when I first learned it back in 2004. Additionally, as someone who once taught a first-year university course called “Introduction to C++ for Engineers” in 2017 I can confidently say that Python is still one of the best introduction languages into the world of programming due to how you are essentially forced to have nice looking indented code and because of its ease/versatility to apply and blend it into many areas of our digital lives compared to C++ being quite software/robotics specific; I bet that versatility would have kept my students who were not interested in going the Software Engineering route far more interested in learning to code. I believe you get most of the fundamentals with Python which is what first-year students need and then if they decide to go into a programming discipline then that’s when they can learn C++ with those pesky pointers majority of my students struggled with. As for this course if you’re brand new to coding: just do the provided assignments and a couple extra exercises for each topic – it’s a solid starting point where the interactive teaching through Jupyter Notebook keeps interested through “play”.

Leave a Comment