# Month: May 2021

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 …

## [Google Interview] Find the k Closest Numbers in a Sorted Array

🏢 This is one of the Google interview questions and reported by programmers across the globe as one of the commonly asked questions during interviews. So, can you give the optimal solution to this problem? Problem Formulation Given an integer array or Python list nums, an integer value x and k. Find and return the …

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

## Kata Recursive Replication – Python Solution Video

Problem Formulation The following problem formulation is taken from this Kata. Design a recursive function called replicate(times, number) that returns an array of repetitions of the number argument. For example, replicate(3, 5) should return the list [5, 5, 5]. If the times argument is negative, return an empty array. Do not use loops to solve …

## How to Crop an Image Using OpenCV?

Problem Formulation Given an image stored at image.jpeg, a target width and height in pixels, and a target starting point (upper-left) x and y in the coordinate system. How to crop the given image in Python OpenCV so that the resulting image has width * height size? Here’s an example of how the original image …

## Why should Software Engineers Learn Java?

What made the internet overflow with Java language courses and people searching every other second on Google? If you search for the term “learn Java”, you’ll end up with more than 160 million results. In this article, we’ll examine if this hype is a mere exaggeration or if you as a software engineer should consider …

## Python “from . import x” — What’s the Purpose of the Dot?

You may have seen an import statement from . import your_module with the dot after the from keyword: What Does the Dot Mean? In Python, modules are defined in packages. If you want to import a certain module within a package that may be hierarchically structured, you need to specify the path of your module. …

## A Gentle Introduction to Python’s Time Module

Having looked at the Python date and datetime modules in previous articles, today we’ll take a closer look at the time module and understand how to extract, input, and work with times in our coding. First, I’ll recap on computer time and introduce the time object we’ll be using with the functions we introduce later …

## Matplotlib Text and Annotate — A Simple Guide

You’d like to add text to your plot, perhaps to explain an outlier or label points. Matplotlib‘s text method allows you to add text as specified coordinates. But if you want the text to refer to a particular point, but you don’t want the text centered on that point? Often you’ll want the text slightly …

## Python |= In-Place OR Operator

Have you stumbled upon the strange-looking Python operator A |= B in a code snippet and you don’t know what it means? This article will clarify it once and for all! Let’s start with the short answer: Python’s A |= B applies the | operator in place. Thus, it is semantically identical to the longer-form …

## Are Energy Costs and CapEx Invested in Bitcoin Worth It?

Bitcoin capital expenditure and energy overhead are often criticized to be unsustainably high. But are they worth it in relation to the value provided by the Bitcoin network? TLDR; Capex and energy costs are estimated using the USD value of the transaction fees paid by the Bitcoin traders. The value of the Bitcoin monetary system …

## How to Get All Transactions for a BTC Address in Python?

Problem Formulation Given a single Bitcoin address in the form of a stream of characters such as the address of the first “Genesis” block ever created on the Bitcoin blockchain: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX How to get all transactions for this BTC address in a Python script? Solution To get all transactions of a given Bitcoin address, import …