Python Equal To

The Python equal to (left==right) operator returns True when its left operand is equal to its right operand. Otherwise, it returns False. For example, 3==3 evaluates to True, but 3==2 evaluates to False. Examples Let’s explore a couple of examples regarding the equal to operator. Is 3 equal to 2? What about ‘h’ equal to … Read more

[Interview Question] Longest Substring Without Repeating Characters

[toc] ?️ Company Tags: As reported by numerous programmers across the globe, this question has been asked in coding interviews/rounds by companies like: Amazon Adobe Bloomberg Yelp So, if you are preparing for your upcoming coding interview, then you might well come across this question in your coding round. Can you solve it optimally? Problem … 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

Python Less Than or Equal To

The Python less than or equal to (left<=right) operator returns True when its left operand does not exceed the right operand. When the left operand is greater than the right operand, the <= operator returns False. For example, 2<=3 and 2<=2 evaluate to True, but 3<=2 and evaluates to False. Examples Let’s explore a couple … Read more

Python Greater Than or Equal To

The Python greater than or equal to (left>=right) operator returns True when its left operand is not exceeded by its right operand. When the left operand is smaller than the right operand, the >= operator returns False. For example, 3>=2 and 3>=3 evaluate to True, but 2>=3 evaluates to False. Examples Let’s explore a couple … Read more

Python Less Than

The Python less than (left<right) operator returns True when its left operand is smaller than its right operand. When the left operand is greater than or equal to the right operand, the < operator returns False. For example, 2<3 evaluates to True, but 3<2 and 2<2 both evaluate to False. Examples Let’s explore a couple … 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 Greater Than

The Python greater than (left>right) operator returns True when its left operand exceeds its right operand. When the left operand is smaller than or equal to the right operand, the > operator returns False. For example, 3>2 evaluates to True, but 2>3 and 3>3 both evaluate to False. Examples Let’s explore a couple of examples … Read more

How to Set and Reset Pandas DataFrame Indexes

The set_index( ) and reset_index( ) methods are used on top of a Pandas DataFrame to manipulate its index column. The method set_index( ) is used to set the index of the DataFrame from the existing columns. The method reset_index( ) is used to get back to the default index of the dataset. Pandas set_index … Read more

[NumPy] How to Calculate The Average Along an Axis?

This article explains how to calculate basic statistics such as average, standard deviation, and variance along an axis. We use the NumPy library for linear algebra computations. These three ways are very similar — if you understand one of them, you’ll understand all of them. TLDR; To average a NumPy array x along an axis, … 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