# Month: June 2021

## Python Multiplication Operator

Python’s multiplication operator * multiplies two objects. The semantics of the multiplication depends on the operands’ data types. For example, multiplying two integers performs arithmetic multiplication whereas multiplying a list with an integer performs list concatenation. The specific return value of the multiplication operator is defined in a data types’ __mul__() magic method. Have a …

## The \$31,000,000 Bitcoin Valuation Thesis

In this article, I’ll develop a simple model on how to value Bitcoin. Valuation thesis: Bitcoin will replace the SWIFT bank-to-bank settlement protocol. Valuation methodology. Bitcoin is now the largest, most decentralized, and most secure international monetary network in the world. This makes it a perfect candidate for bank-to-bank settlements of high-value transactions. Currently, these …

## 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 …

## [Google Interview] Find All Numbers That Disappeared in an Array

🏗️ Company Tags: Google Problem Formulation Given an array nums of n integers. Return an array containing all the integers in the range[1, n]that do not appear in nums. ✒️ Here, nums[i] is in the range [1, n]. ⚠️Constraints: n == nums.length 1 <= n <= 105 1 <= nums[i] <= n 💡Examples Let’s have a look at some examples …

## Python For Loop Inside Lambda

Problem: Given an iterable, how to print it using a for loop within a lambda function. Overview In this tutorial, we will learn why it is not a smart idea to use for loop inside Lambda in Python. This is a frequently asked question by programmers and newbies. Hence, it needs to be addressed as …

## Python Subtraction Operator

Python provides the subtraction operator – to subtract one object from another. The semantics of the subtraction depends on the operands’ data types. For example, subtracting two integers performs the arithmetic difference operation whereas subtracting two sets performs the set difference operation. The specific return value of the minus operator is defined in a data …

## Python Program to Add Two Numbers

Add Two Integers The most basic Python program to add two integer numbers stored in variables num_1 and num_2 is the expression num_1 + num_2 using the addition operator. The following code shows how to add two numbers 20 and 22 and print the result 42 to the shell: Add Two Integers with User Input …

Python provides the addition operator + to add two objects. The semantics of the addition depends on the operands’ data types. For example, adding two integers perform arithmetic addition whereas adding two lists performs list concatenation. The specific return value of the addition operator is defined in a data types’ __add__() magic method. Have a …

## How to Generate a Random String in Python?

Problem Formulation You are tasked with writing Python code to generate a random string.  The string should contain any of the printable characters on your keyboard.  Letters, numbers, and punctuation marks are valid, and we’ll leave out any whitespace characters. What’s the best way to solve this in Python? Method 1: List Comprehension and random.randint() …

## 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 …

## 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. …

## 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 …