Found 34489 Articles for Programming

How to Get a sorted list of random integers with unique elements using Python?

Asif Rahaman
Updated on 28-Jul-2023 14:51:57

166 Views

Generating random numbers is one of the most popular techniques in programming, statistics, machine learning models, etc. Generating a sorted list of random integers with unique elements is a subdomain of the task. However, computers are deterministic machines, so generating random numbers through our implementation is only sometimes a smart idea. In this article, we will explore how to Get a sorted list of random integers with unique elements using Python. Utilizing Sample Function Of Random Module The sampling method generates random samples of k elements from a given population. It takes two required parameters first is the list of ... Read More

How to generate k random dates between two other dates using Python?

Asif Rahaman
Updated on 28-Jul-2023 14:48:44

1K+ Views

Generating random data is important in the field of data science. From building Neural Networks forecasting, stock market data, etc., often come with dates as one of the parameters. We may need to generate random numbers between the two dates for statistical analysis. This article will show how to generate k random dates between two given dates Use random and date time Modules The date time is an in-built library of Python to deal with time. The random module, on the other hand, helps to produce random numbers. Hence, we can combine the random and date time modules to generate ... Read More

Get the Most recent previous business day using Python

Asif Rahaman
Updated on 28-Jul-2023 12:39:24

1K+ Views

In today's fast-paced based business environment and with a huge amount of work going on around the world, developers need to analyze the dates accurately up to date. The business days are different from normal days. Business days are different from normal days. Typically the days on which office works run, like the stock market, government officials, schools, offices, banks, etc. While dealing with real-world problems involving such institutions, developers must design the systems as per the business days. This article will explain how to get the most recent business day in Python. Use The date time Library The date ... Read More

Gaussian fit using Python

Asif Rahaman
Updated on 28-Jul-2023 12:33:33

4K+ Views

Data analysis and visualization are crucial nowadays, where data is the new oil. Typically data analysis involves feeding the data into mathematical models and extracting useful information. The Gaussian fit is a powerful mathematical model that data scientists use to model the data based on a bell-shaped curve. In this article, we will understand Gaussian fit and how to code it using Python. What is Gaussian Fit A bell-shaped curve characterizes the Gaussian distribution. The bell-shaped curve is symmetrical around the mean(μ). We define a probability density function as follows f(x) = (1 / (σ * sqrt(2π))) * exp(-(x - ... Read More

Minimum addition/removal of characters to be done to make frequency of each character prime

Naveen Singh
Updated on 31-Jul-2023 13:29:57

61 Views

Optimising character frequency for primality is a challenging task in computer science that entails identifying the smallest number of character additions or removals required to make the frequency of each character in each string a prime integer. Cryptography, data reduction, and natural language processing are just a few of the applications for this issue. The frequency of characters in a string can be optimised for primality in this tutorial using a C++ method. We will start by involving further into the problem description and then propose an efficient solution. Method Dynamic programming Approach minOperations function Method Method ... Read More

How to merge images with same size using the Python 3 module pillow?

Tarun Singh
Updated on 31-Jul-2023 09:59:26

259 Views

The pillow or PIL is a powerful Python library for handling and manipulating images. One of the most common tasks in image processing is merging multiple images into a single image. It provides a range of functions for loading, manipulating, and saving images in various formats. One of the main features of Pillow is its support for image merging. It supports a variety of images including “jpeg”, “png”, “bmp”, “gif”, “ppm”, “tiff”. With this module, we can do almost anything with digital images like basic image processing functionality, point operations, filtering images using built-in convolution kernels, and color space conversions. ... Read More

Segregate 1s and 0s in separate halves of a Binary String

Naveen Singh
Updated on 28-Jul-2023 13:10:17

198 Views

In this tutorial, we need to separate all 1s and 0s of the given binary string in the two halves. Here, we need to take a substring from the given string and reverse it to separate 0s and 1s in different parts. Ultimately, we need to count the total number of reversals required for substring to separate 1s and 0s in two halves. Problem statement − We have given a binary string of even length. We need to take any substring from the given string multiple times and reverse it to separate it into two halves. We need to print ... Read More

Modify string by replacing all occurrences of given characters by specified replacing characters

Naveen Singh
Updated on 28-Jul-2023 13:07:54

91 Views

In this problem, we need to replace the characters of the given string according to the characters given in the array of pairs of characters. We will discuss two different approaches to solving the problem. In the first approach, we iterate through the characters of the given string and pairs of characters to replace each character. In the second approach, we will use an array of length 26 to store the replaced character related to each character and change the character of the given string. Problem statement − We have given a string str containing N lowercase alphabetic characters. Also, ... Read More

Minimum removals required such that a string can be rearranged to form a palindrome

Naveen Singh
Updated on 28-Jul-2023 13:06:05

729 Views

In this problem, we need to remove the minimum characters from the string and rearrange the remaining characters to make the string palindromic. To solve the problem, the first question we should ask ourselves is when we can make string palindromic. In below two cases, we can make string palindromic. If each character’s frequency is even in the given string. If only one character’s frequency is odd and all other characters' frequency is even. So, we need to remove minimum characters to make each character’s frequency even except for any single character. Problem statement − We have given ... Read More

Maximum Spanning Tree using Prim’s Algorithm

Naveen Singh
Updated on 28-Jul-2023 12:24:43

1K+ Views

Introduction One of the most important ideas in graph theory and data structures is the Maximum Spanning Tree using Prim's Algorithm. It tries to find the tree that links all of the points in a graph with the most weighted edges overall. Prim's Algorithm quickly finds this tree by adding the edges with the most weight after each iteration. It is a key part of network design and clustering uses. Prim's Algorithm Overview and Basics Prim's method is a popular greedy method that is used to find the MiST or the minimum spanning tree of a connected, weighted graph. ... Read More

Advertisements