How to Print All Digits of a Large Number in Python?

In this tutorial, we will learn the different methods to print a large number in Python. And the contrast between printing integers or floats in those situations.Β Β  As you go through the article, feel free to watch my explainer video: Problem Formulation: Float vs Integer Printing Python by default prints an approximation in the case … Read more

The Shortest Quicksort Algorithm in Python

Quicksort is not only a popular question in many code interviews – asked by Google, Facebook, and Amazon – but also a practical sorting algorithm that is fast, concise, and readable. Because of its beauty, you won’t find many introductions to algorithms that don’t discuss the Quicksort algorithm. In this one-liner tutorial, you’ll learn about … Read more

[FIXED] fatal error: Python.h: No such file or directory

[toc] Problem Statement: How to fix “fatal error: Python.h: No such file or directory“? What is a “fatal” error? A fatal error causes a program to end with practically no warning without even saving its state. It usually occurs when an application attempts to access a piece of invalid information or data. The program closes … Read more

[FIXED] UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xa5 in position 0: invalid start byte

Introduction Problem Statement: How to fix “UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xa5 in position 0: invalid start byte” in Python? Using a specific standard to convert letters, symbols and numbers from one form to another is termed as Encoding. A Unicode character can be encoded using a variety of encoding schemes. The most common … Read more

PIP Commands – A Simple Guide

When working with Python, a programmer often encounters situations where she needs to install packages not contained in the Standard Library. In such situations, she must install modules from online repositories using packager installers. The goal of this article is to help beginners develop a working knowledge of pip (acronym for “PIP Installs Packages”) as … Read more

Convert Bytes to String [Python]

[toc] Overview Problem Statement: How to convert bytes data to string data in Python? Example: The following example illustrates how the decode() method converts a byte string to string. (We will dive into the details of this solution soon!) Output: Note: Difference between Byte and String Objects in Python Strings are normal sequences of characters, … Read more

Pandas DataFrame GroupBy and Window – Part 2

The Pandas DataFrame has several Function Applications, GroupBy & Window methods. When applied to a DataFrame, these methods modify the output of a DataFrame. Part 2 of this series focuses on GroupBy & Window methods and delves into each item listed above. Preparation Before any data manipulation can occur, two (2) new libraries will require … Read more

Pandas DataFrame Function Application – Part 1

The Pandas DataFrame has several Function Applications, GroupBy & Window methods. When applied to a DataFrame, these methods modify the output of a DataFrame. Part 1 of this series focuses on Function Applications and delves into each of the following methods. Preparation Before any data manipulation can occur, two (2) new libraries will require installation. … Read more

Python __rdiv__ Magic Method

The Python __rdiv__() magic method overrides the reverse division operation for a custom object in Python 2. In Python 3, it was replaced by the __rtruediv__() and __rfloordiv__() dunder methods. The Python __rtruediv__() method is called to implement the normal division operation / called true division and apply it in reverse. The Python __rfloordiv__() method … Read more

How to Change The Size of Figures Drawn with Matplotlib?

[toc] If you want to dive deep into this mind-blowing library, please feel free to have a look at this tutorial – Matplotlib β€” A Simple Guide with Videos. However, in this tutorial, we will focus upon our mission-critical question, i.e., How do you change the size of figures drawn with matplotlib? Note: Before diving … Read more

Python __neg__ Magic Method

To customize the behavior of the negation operator -x, override the __neg__(self) dunder method in your class definition. Python internally calls x.__neg__() to calculate the inverse (negation) of an object, i.e., -x. If the __neg__() method is not defined, Python will raise a TypeError. Syntax __neg__(self) To use the negation operator -x on a custom … Read more