In Java, the do-while and while loops are used to repeat a block of code multiple times based on a condition. These loops help us to avoid writing the same code again and again. Both loops are used when we don't know exactly how many times the loop should run. In this article, we will understand the difference between the while loop and the do-while loop. The while Loop The while loop in java executes one or more statements after testing the loop continuation condition at the start of each iteration. Syntax The while loop follows the syntax given ... Read More
Backreferences in regular expressions allow us to reuse a previously recorded group inside the same regex pattern. This ability is very useful when we want to match recurrent patterns in strings. What are Backreferences? A regular expression reference to a previously recorded group is called a backreference. When parentheses "()" are used in a regex pattern, a group is formed. Each group is assigned a number; the number for the first group is 1. We can refer to these recorded groups in our regex by using the backslash \ after the group number. Basic Syntax Here is the basic ... Read More
In this article, we are going to find the longest common substring from more than two strings in Python. The first and only approach for finding the longest common substring is by using the Longest common substring Algorithm. We will define a function that accepts 2 strings, then we will iterate over both the strings and find for common subsequence and calculate the length. We will check entire string by iterating over and calculating the length of the sub-sequences and we will return the longest common subsequence. We will get an empty string as output if there are not any ... Read More
A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched. Quadratic probing is a collision resolving technique in Open Addressed Hash tables. It operates by taking the original hash index and adding successive values of an arbitrary quadratic polynomial until an open slot is found.This is a C++ program to Implement Hash Tables with Quadratic Probing.AlgorithmFor search a key value:Begin Declare function SearchKey(int k, HashTable *ht) int pos = ... Read More
When programming in Python, proper indentation is essential as the language uses it to define the structure of the code such as loops, functions and conditionals. Even minor mistakes in indentation can lead to errors or unexpected behavior by making it critical to maintain consistency. Vim Editor Vim is a highly efficient text editor which offers flexible configuration options to automate indentation by ensuring that our code is properly formatted according to Python's standards. By adjusting Vim's settings we can configure it to handle indentation in Python files with ease. This includes converting tabs to spaces, setting the appropriate indentation ... Read More
Monitoring Python files for changes is essential in many development and automation scenarios such as triggering automatic reloads, running tests, or updating services when the source code is modified. This is particularly useful in web development, machine learning pipelines or custom tooling where real-time responsiveness to file updates is beneficial. One effective way to achieve this in Python is by using the watchdog library which is a simple and efficient tool that listens for file system events like creation, modification, and deletion. With watchdog library the developers can set up observers that watch specific directories and respond to the changes ... Read More
The command line is the place where executable commands are given to the operating system. In Python, command-line arguments allow users to pass information to a script when it's executed from the terminal. A Python script can be executed by writing its name in front of the Python executable on the command line. Following is the example command which executes the Python file named sample.py - python sample.py If we need to pass arguments to a script, we can pass them at the time of execution, separating them by a space as shown below - python test.py Hello TutorialsPoint Python ... Read More
An image slider is a user interface component in JavaScript that allows users to view a series of images in a slideshow format. It is also known as a carousel or slideshow. An image slider consists of navigation buttons (such as next and previous buttons) that allow users to navigate from one image to the other. With the help of basic HTML for structuring and CSS for designing or making the image slider presentable, along with simple JavaScript logic, you can create an image slider efficiently. This article will guide you through creating a basic image slider with navigation buttons. ... Read More
In Python, determining the current directory of program execution is a common task, especially when working with file operations, configuration of files or dynamically accessing resources. The current directory refers to the location from which the script is being run, but not necessarily where the script file resides. Python provides two main ways to retrieve the current directory information, using the os module and the pathlib module. Significance of the Current Directory The current directory in Python is the folder from which our script is being executed. It’s important to find the current directory because all the relative file paths ... Read More
In Python, while working with files, we may need to duplicate binary files. In this article, we will go through various ways to explore efficient methods of copying binary files in Python. First, we need to understand about Binary format and Binary File Copying, before proceeding with various ways to copy a binary file. What is Binary Format? Binary format is a method of storing data in the form of binary digits, such as 0s and 1s. Unlike text format, which represents data using readable characters like letters and numbers, binary format stores data as raw byte sequences. Binary file ... Read More