To calculate the length of a Linked list, we traverse the list, counting each node until we reach the end, where the next node is None. Suppose, we have a singly linked list, we have to find its length. The linked list has fields next and val. So, if the input is like [2 -> 4 -> 5 -> 7 -> 8 -> 9 -> 3], then the output will be 7. The two commonly used methods to find the length of a linked list are as follows - ... Read More
In Python, whenever we try to read or write files we don’t need to import any library as it’s handled natively. The open() function opens a file and returns a file object. The file objects contain methods and attributes which latter can be used to retrieve information or manipulate the file you opened. File Operations The file is a named location on the disk to store related information, as the file is having some name and location, it is stored in the hard disk. In Python, file operation is performed in the following order - ... Read More
When it is required to find the maximum element in a tuple list (i.e. list of tuples), the 'max' method and the 'operator. itemgetter()' method can be used. The itemgetter fetches a specific item from its operand. The 'max()' method gives the maximum value present in an iterable that is passed as an argument to it. Some of the common methods to find the maximum element in a tuple list are as follows. 'itemgetter()' function: Used for retrieving items from an iterable object such as a ... Read More
Depending on the flexibility and complexity required, we can split a string on multiple delimiters in several ways such as using Python's re.split() method, which is a combination of various string methods. Some of the commonly used approaches to split strings on multiple delimiters. str.replace() and str.split() re.split() Method translate() ... Read More
To merge all CSV files, use the GLOB module. The os.path.join() method is used inside the concat() to merge the CSV files together. Some of the common methods we can use to merge multiple CSV Files into a single dataframe are as follows - os.path.join() and glob Merging CSV Files with glob Pattern ... Read More
The OpenCV platform provides a cv2 library for Python. This can be used for various shape analyses which is useful in Computer Vision. To identify the shape of a circle using OpenCV we can use the cv2.HoughCircles() function. It finds circles in a grayscale image using the Hough transform. Common Approaches Some of the common methods to find circles in an image using OpenCV are as follows - Circle detection using Hough transform OpenCV ... Read More
Machine learning (ML) has become one of the fastest-growing fields in technology, empowering systems to learn from data, adapt, and improve. While Python dominates this domain, other languages are beginning to gain traction due to their performance, safety, and concurrency features—one such language is Rust.Rust, known for its memory safety without needing a garbage collector, brings considerable benefits to machine learning, especially when building performant and safe systems. In this article, we'll explore how to build a simple machine learning model in Rust. Whether you’re a Rustacean or a beginner, this guide will provide step-by-step instructions on creating a basic ... Read More
In Python, the Fraction module supports rational number arithmetic. Using this module, we can create fractions from integers, floats, decimals, and other numeric values and strings. The constructor of this class accepts Numerator and Denominator as parameters and creates Fractions from them. The default value of the numerator is 0 and the default value of the denominator is 1. The cost raises ZeroDivisionError when the denominator is 0. Creating Fraction Instances At first, we will see how the class can create fractions using Numerator and Denominator. Example from fractions import Fraction as frac print(frac(45, 54)) print(frac(12, 47)) print(frac(0, 15)) ... Read More
Many computer applications need random numbers to be generated. However, none of them generate an actual random number. Python, like any other programming language, uses a pseudo-random generator. Python’s random generation is based on the Mersenne Twister algorithm that produces 53-bit precision floats. The technique is fast and thread-safe but not suitable for cryptographic purposes. Python’s standard library contains the random module which defines various functions for handling randomization. The following functions handle random integer number generation. random.seed() − This function initializes the random number generator. ... Read More
AI has revolutionized software development. Developers can now work more efficiently and innovate faster because of it. From generated code to debugging, AI-powered tools have significantly made difficult tasks easier, thereby increasing productivity. In this article, we shall ponder some of the best AI tools for software developers and how they make the development process smoother, faster, and more efficient. 1. GitHub Copilot Among the most revolutionary tools that AI has developed for developers is GitHub Copilot. GitHub Copilot is an AI code completion tool, developed by GitHub in partnership with OpenAI, which directly integrates into your code ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP