Linked Lists in Python

In this blog post you will learn how to implement a linked list in Python from scratch. We will understand the internals of linked lists, the computational complexity of using a linked list and some advantages and disadvantages of using a linked list over an array. Introduction Linked list is one of the most fundamental … Read more

Python format() Function: No-BS Guide by Example

The web is filled with shitty tutorials about Python’s formatting feature. At times, it can become really confusing—and it’s hard to see the forest for the trees. In this tutorial, I’ll try to gradually build a basic understanding of the built-in format() function, what it does, and how you can use it to become a … Read more

The K-Means Algorithm in Python

Hey Finxters! Today we are going to talk about one of the most popular clustering algorithms: K-Means. Ever wondered how to organize seemingly unstructured data, making sense of unordered objects, in an easy way? For example, you might need to: perform customer segmentation store files based on their text content compress images with your own … Read more

Python float() Function

Python’s built-in float(value) function converts the argument value to a float number. For example, float(’42’) converts the string value ’42’ into the float number 42.0. Argument value A Python object to be converted into a float number. The value object must have an __float__() method that returns the associated float number—otherwise a ValueError will be … Read more

Python int() Function

Python’s built-in int(value) function converts the argument value to an integer number. For example, int(’42’) converts the string value ’42’ into the integer number 42. The int() function on a float argument rounds down to the closest integer. Argument value A Python object to be converted into an integer number. The value object must have … Read more

How to Send UDP Multicast in Python?

Problem Formulation: How to send and receive UDP multicast messages in Python? Background: Multicast is a distributed systems concept for group communication over a network (one-to-many or many-to-many). The choice of the network “transport layer” which the Multicast uses determines its type—for example, IP Multicast is sending a multicast over the IP layer and UDP … Read more

How to Send UDP Messages in Python?

Problem Formulation: How to send and receive UDP messages in Python? Background: The User Datagram Protocol (UDP) network layer allows you to send messages without providing deliverability guarantees. UDP is unreliable—massages may be lost or delivered out of order. But this makes UDP also fast, lightweight, and the protocol of choice for many streaming scenarios … Read more

How to Remove Everything After the Last Character in a String?

Problem Formulation Given string s, and character c. How to remove all characters in s after the first occurrence of c? Example Given: – string s = ‘hello world’, and – empty space character c = ‘ ‘. Desired result: ‘hello’ Method 1: string.index() + slicing To remove everything after the first occurrence of character … Read more

How To Cut A String In Python?

Problem: Given a string; how to split/cut the string and extract the required characters? In this article, we will be discussing some interesting scenarios which allow us to split or cut a string and extract the necessary portion of the string that we need. Let us dive into each example/scenario and have a look at … Read more

How to Remove a Non-Empty Folder in Python?

Problem Formulation: Given a path to a folder as a Python string. The folder is non-empty. How to remove the whole folder in your Python script? Example: Say, you have the path=’path/to/folder’ in your Python script and it contains some files and subfolders: path –to —-folder ——file1.dat ——file2.dat ——subfolder1 ——–file3.dat ——subfolder2 ——–file4.dat You want to … Read more