View Post

Python Slice Assignment

Slice assignment is a little-used (but beautiful) Python feature that helps you replace a subsequence of a sequence. One of my Finxter users, Mike, asked the following great question: “I was going through a lot of slicing puzzles on the Finxter site, I came across this: I originally answered [‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’] but got it wrong.” This …

View Post

Python Ziiiiiiip! [A helpful guide]

Many coders struggle with understanding the zip function. Let’s fix this for you. The zip function takes a number of iterables and aggregates them to a single one by combining the i-th values of each iterable into a tuple for every i. (An iter-able is an object that contains multiple elements over which you can iterate. Examples are lists, sets, …

View Post

Python Linear Regression in One Line [A Helpful Illustrated Guide]

This one-liner uses two Python libraries: NumPy and scikit-learn. The former is the de-facto standard library for numerical computations (e.g. matrix operations). The latter is the most comprehensive library for machine learning which implements hundreds of machine learning algorithms and techniques. You may ask: “why are you using libraries in a Python one-liner? Isn’t this cheating?” No! You want to …

View Post

Sets in Python – with Harry Potter Examples

When I worked on my recent project using Python’s built-in set data structure, I wondered “how exactly does the set data structure work in Python?”. I searched the web for set tutorials but not a single article could answer all of my questions! So I wrote this 4000-word article that teaches you everything you need to know about sets in …

View Post

The Reduce Function in Python 3: Simply Explained

The reduce function in Python reduces a sequence of elements to a single element by repeatedly applying a specified function that takes two sequence elements and merges them to a single element. By repeating this behavior, ultimately, only a single value will remain — the sequence is reduced to a single element. Here is an example (one-liner code puzzle): What …

View Post

How to Conditionally Select Elements in a Numpy Array?

You have a Numpy array. You want to select specific elements from the array. But you can neither use slicing, nor indexing. What can you do? In this short tutorial, I show you how to select specific Numpy array elements via boolean matrices. You can even use conditions to select elements that fall in a certain range: Plus, you are …

View Post

How to 10x Your Coding Productivity

Learn Less Random Stuff A loyal reader of my Python email course, Lee, asked the following question: “One of the first things I learned was that I needed to learn how to use the Powershell in addition to Python so I could write the programs in the IDE, then run them in the shell. […] Next, I learned about regular …

View Post

How to Calculate the Levenshtein Distance in Python?

After reading this article, you will know exactly how to calculate the edit distance in Python. Learning requires opening your knowledge gap first. So let’s do this. What is the output of the following Python puzzle showing you a concise code snippet to calculate the edit distance in Python? (source) Python Source Code Now, this is a hard nut to …

View Post

How to Go Full-Time ($3000/m) as a Python Freelancer

… Without Working Full-Time Hours!          In this article, you are going to learn my exact strategy how to earn $3000 per month as a Python freelancer without actually working full-time and without sacrificing time with your family! This article is based on the following webinar I gave to my community of Python coders. You can also watch the webinar …

View Post

[$$$] How to Find Clients as a Python Freelancer?

Do you want to sell your coding skills as a Python freelance developer but you don’t know where to start? This article shows you the best places to look for new clients – so that you never run out of work (and $$$ cash) again. There are three types of freelancing projects: small, medium, and large gigs. Let’s dive in …