How to Make a 4×4 Magic Square in Python

Magic Squares is one of the oldest recreational mathematics games. The smallest magic squares are three by three, but they can be made up to any size with the right formulas. Odd and even ordered magic squares have different formulas, but can be easily generated. Programming has made it even easier to make magic squares,Continue reading “How to Make a 4×4 Magic Square in Python”

Graph Algorithms: Kruskal’s Algorithm in Python

Data structures and algorithms are a cornerstone of computer science. In our journey so far, we’ve looked at basic data structures like stacks, queues, and dequeues, linked lists and binary trees, and algorithms like sorting algorithms, tree algorithms, and Dijsktra’s algorithm. Now, let’s take a look at another important graph algorithm – Kruskal’s. Kruskal’s algorithmContinue reading “Graph Algorithms: Kruskal’s Algorithm in Python”

Nested Lists in Python

Nested lists are Python representations of two dimensional arrays. They are used to represent lists of lists. For example, a list of grocery lists for the month or matrices we can multiply. In this post we’re going to go over how to use Python to create and manipulate nested lists. We’ll go over: Python NestedContinue reading “Nested Lists in Python”

Level 1 Python: Pure Python Matrix Multiplication

Level 1 Python projects are projects that are more logically complex or require more libraries than the ones in the Super Simple Python series. Pure Python matrix multiplication is one of the projects that is more logically complex, we won’t be using any external libraries here. Most of these projects should take you between 30Continue reading “Level 1 Python: Pure Python Matrix Multiplication”

Python Single Responsibility Principle

You’ve probably heard about programming principles. A piece of advice that always gets thrown around is “have the smallest classes/functions/modules possible”. What does that mean though? How do you make a function as small as possible? The single responsibility principle. This programming principle dictates how small a function could possibly be. In this post, we’llContinue reading “Python Single Responsibility Principle”

Level 1 Python: Scientific Calculator

As part of the Super Simple Python series, we made a basic, four-function calculator. Since then, we’ve also covered how to do math in Python. From the math tutorial, we learned how we could use the Python math module to perform operations outside of the basic add, subtract, divide, and multiply.  Let’s use the mathContinue reading “Level 1 Python: Scientific Calculator”

List Directories, Files, and Subdirectories with Python

Creating, updating, and interacting with files is an integral part of data pipelines. In order to interactively access files, we have to be able to list them. There are three ways to list the files in a directory for Python. In this post we’ll cover how to use the os module and three of itsContinue reading “List Directories, Files, and Subdirectories with Python”

Download any YouTube Video with Python

Over 100,000 people search for ways to download YouTube videos every month. Here’s how you can download a YouTube video with Python, for free. In this post we’re going to cover how to use the youtube_dl library to download YouTube videos with Python. We’re going to first learn about what the youtube_dl library is, andContinue reading “Download any YouTube Video with Python”

Combine Files that Start with the Same Words with Python

Recently I had to combine a bunch of files that started with the same prefix. I did an NLP analysis of a YouTube series where I had to split up my API calls for each episode. After getting the partial analysis results, I wanted to combine them into one file for each episode. This isContinue reading “Combine Files that Start with the Same Words with Python”

Private Variables in Python

There are three variable scopes you need to know. There are global variables, public variables, and private variables. Global variables can be accessed from all functions and modules in a program. Ideally they are only declared once in a whole program. Public variables belong to certain classes, but are visible to other classes, functions, andContinue reading “Private Variables in Python”

%d bloggers like this: