Division in Python

The double-frontslash // operator performs integer division and the single-frontslash / operator performs float division. An example for integer division is 40//11 = 3. An example for float division is 40/11 = 3.6363636363636362. A crucial lesson you need to master as a programmer is “division in Python”. What does it mean to divide in Python? … Read more

Five Types of Inheritance in Python

In a previous article, we introduced the topic of object-oriented programming, or OOP for short. Then, we discussed classes and the topic of inheritance. This article will do a quick recap of inheritance, what it is, and why you’d use it. Then we’ll introduce the different types of inheritance you might encounter in your programming … Read more

K-Nearest Neighbors (KNN) with sklearn in Python

The popular K-Nearest Neighbors (KNN) algorithm is used for regression and classification in many applications such as recommender systems, image classification, and financial data forecasting. It is the basis of many advanced machine learning techniques (e.g., in information retrieval). There is no doubt that understanding KNN is an important building block of your proficient computer … Read more

Python Not Equal To

The Python not equal to (left!=right) operator returns True when its left operand is not equal to its right operand as defined by the __ne__() magic method. Otherwise, it returns False. For example, 3!=2 evaluates to True, but 3!=3 evaluates to False. Examples Let’s explore a couple of examples regarding the not equal to operator. … Read more

An Introduction To Python Classes – Inheritance, Encapsulation, and Polymorphism

This article continues from Introduction to Classes – Part One, where we explained what classes are, their components, and why we use them. We also looked at some unique characteristics of classes that assist us in creating cleaner code. If you haven’t read Part One and are new to classes, I suggest reading that introduction … Read more

[Tutorial] K-Means Clustering with SKLearn in One Line

If there is one clustering algorithm you need to know – whether you are a computer scientist, data scientist, or machine learning expert – it’s the K-Means algorithm. In this tutorial drawn from my book Python One-Liners, you’ll learn the general idea and when and how to use it in a single line of Python … Read more

Python Operators Overview

What Are Python Operators? Python operators are special syntactical sugar to run basic operations without calling their respective methods. For example, you can use the + operator in a + b instead of the more clunky .add() method in a.add(b). Each operator has a unique symbol that is placed between the two arguments called operands. … Read more

Introduction to Python Classes

This article introduces classes in Python, explaining what they are, their components, and why we use them. We’ll also look at some unique characteristics of classes to assist us in creating cleaner code. When I first began coding, the subject of classes in Python was a complete mystery to me. The explanations and jargon employed … Read more

Method Overriding vs Overloading in Python [+Video]

Method overriding vs overloading in Python—what’s the difference? If you’re short on time—here it is: Method overloading: creating a method that can be called with different arguments such as m() and m(1, 2, 3). Method overriding: overwriting the functionality of a method defined in a parent class. In method overloading, methods in a given class … Read more

5 Brag-Worthy Python Projects

Hacking Alexa’s Voice Recordings After David’s mother passed away, he wanted to hear her voice again. As she used Amazon Alexa, he figured, he could download the voice recordings from the Alexa device. But Amazon didn’t provide an interface for it. Fortunately he found this project online: [Cool Project] Hacking Alexa’s Voice Recordings After following … Read more