In this article, we will explore how to find missing and additional values in two lists. This type of comparison is can be encountered in the real-world scenarios such as data validation or system synchronization. The task is to determine which elements are missing in one list and what unexpected elements were received. This can be achieved by using the python built-in data structures like sets that allows for easy comparison. Using set() Function The python set() function is used to used to create a new set. A set is a collection of unique elements (each ... Read More
In Python, Lists are one of the built-in data type used for storing collections of data. Python list is a sequence of comma separated items, enclosed in square brackets[]. They are flexible, easy to manipulate and widely used in various applications. In this article, we will explore to list the difference between two lists. Python provides the several built-in methods for achieving this. Using set.difference() Method The python set.difference() method is used to return the new set containing the elements that are present in the first set but not in any other sets provided as arguments. ... Read More
Inter-process communication (IPC) is essential, When multiple processes need to share the data and work together. In Python, multiprocessing module provides various IPC mechanisms, Out of which one is the pipe. The pipe allows the data to be transferred from one process to another in a two-way (duplex) or one-way mode. It is useful when a parent process creates a child process and want them to exchange messages or data. Python multiprocessing.Pipe() Method The multiprocessing.Pipe() is a method in the Python multiprocessing module that return the pair of connection objects connected by a pipe. This pipe can be ... Read More
In this article we are going to learn about class or static variables on python. The class variables or static variables that are used to share across all the instances of a class. Unlike the instance variables which are specific to each object, Class variables maintain the common value for all the objects of the class. They are defined within the class but outside any instance methods, making them accessible to all the instances. These variables are used when we want to have a single shared state or value among all instance. Example 1 Let's look ... Read More
In Python, the module is a file containing Python definitions and statements. For keeping the code organized, we often write functions in separate modules and import them into main program. While importing the entire module, sometimes we only need a single function from it. Python provides a direct way to do this using the from module_name import function_name syntax. Importing sqrt() from math module In this approach, we are going to use from math module importing the sqrt to import only the sqrt function. The Python sqrt() function is used to calculate the square root of ... Read More
In this article, we are going to learn about the logical operators on strings in Python. The logical operators such as and, or, and not are used to combine the conditional statements and control the flow of logic. While they are commonly used with the Boolean values, they can also be used with strings and other non-Boolean types.Logical Operators on String in Python? In Python the non-empty strings are considered as true, and the Empty strings ("") are considered as false. When the logical operators are applied to the strings, they do not return Boolean values directly; instead, they return one ... Read More
Python is a flexible programming language that consists of thousands of libraries and libraries. As the Python environment grows with the installations, it is important to be able to check which packages are currently installed. Whether you are debugging or documenting the environment, listing locally installed python modules can be useful. In this article, we will explore the different ways to get a list of locally installed python modules using the built-in tools and external commands. Using pip list The pip is the Python package installer and the list is tje subcommand that shows all the installed ... Read More
While working in python, we will need external libraries or modules to solve the specific problems. This can be done by using the python built-in package manage pip making it easy to install, upgrade and manipulate packages. In this articles, we will learn how to use pip to install the python modules in easy way. pip The pip stands for 'pip installs packages'. It is the default package installer for python and is used to install the packages from the python package index and other indexes. For checking if the pip is installed or not, run the ... Read More
In NLP(Natural Language Processing), stop words are the words that are filtered out before or after processing text data, such as "is", "and", "a" etc. These words do not add meaning to the text and can be removed to improve the efficiency. The Natural Language Toolkit (NLTK) is the python library that provides the easy to use interface and the tools for text processing such as tokenization and stop word removal. In this article, we will explore how to remove stop words using NLTK. NLTK Stop Words Before going to use the NLTK stop words, we have ... Read More
Lexicographical order is similar way the words are arranged in a dictionary. In this article, we are going to learn how to sort the words in lexicographical order, which means arranging them in alphabetical order (A-Z). Python provides built-in methods like split() and sorted() to perform this operation. Using Python split() Method The Python split() method is used to split a string by using the specified separator. This separator is a delimiter string and can be a comma, a full stop, or any other character to split a string. Syntax Following is the syntax of Python str.split() method ... Read More