Python __str__()

Syntax object.__str__(self) The Python __str__ method returns a string representation of the object on which it is called. For example, if you call print(x) an object x, Python internally calls x.__str__() to determine the string representation of object x. This method is also used to implement the built-in str() function. We call this a “Dunder … Read more

[SOLVED] ValueError: invalid literal for int() with base 10

[toc] Introduction Problem: How to fix “ValueError: invalid literal for int() with base 10“? In Python, you can convert the values of one type into another. That means you can convert the integer strings into integers, integers into floats, floats into strings, etc. But one such conversion that Python dislikes is to change a float … Read more

Pandas DataFrame Methods

The Pandas DataFrame is a data structure that organizes data into a two-dimensional format. If you are familiar with Excel or Databases, the setup is similar. Each DataFrame contains a schema that defines a Column (Field) Name and a Data Type.   This article delves into the methods available for DataFrame Iteration. This article also … Read more

Common Consensus Mechanisms in Blockchains

We know what a blockchain is and its wide applications. Blockchain is a distributed computing technology involving multiple nodes distributed across geographies. The problem is to ensure that each node gets the exact copy of the data. Hence, some protocol is needed to achieve this unison or consensus. This post tries to cover the need … Read more

Python __ne__ Magic Method

To customize the behavior of the non-equality operator x != y, override the __ne__() dunder method in your class definition. Python internally calls x.__ne__(y) to compare two objects using x != y. If the __ne__() method is not defined, Python will use the is not operator per default that checks for two arbitrary objects whether … Read more

Python Math floor(), ceil(), trunc(), and modf()

This article is the first of several articles discussing functions from the math module from the Python Standard Library. The articles are organized thematically; functions that are closely related to each other are discussed in the same article. In this article, we discuss four functions: math.floor, math.ceil, math.trunc, and math.modf. They are all related to … Read more

The Best-First Search Algorithm in Python

You can watch the slides as a GIF here: And download the slides as PDF here. What’s the Best-First Search Algorithm? After several articles on uninformed search algorithms, we continue our journey to informed search algorithms. The first one in the series is the Best-First search algorithm. In general, informed search algorithms use some kind … Read more

Pandas cut() – A Simple Guide with Video

In this tutorial, we will learn about the Pandas cut() function. This function bins values into separate intervals. It is mainly used to analyze scalar data. Syntax and Documentation Here are the parameters from the official documentation: Parameter Type Description x array-like The one-dimensional input array to be binned. bins int, sequence of scalars, orIntervalIndex … Read more

PowerShell Loops – A Simple Guide with Video

PowerShell foreach Loop Syntax: The keyword ‘foreach‘ is used in Windows PowerShell to iterate through a series or list of items, usually with the intent of performing operations using each item.  Example: In the following example, we use PowerShell to read the contents of a text file (C:\Temp\ServerList.txt) filled with server names, storing the values … Read more