Found 34488 Articles for Programming

Iterate Over Words of a String in Python

Sai Mohan Pulamolu
Updated on 09-Aug-2023 15:56:15

646 Views

In this article, we will learn various methods to iterate over words of a string in Python. Understanding how to access and manipulate words in a string is a very important skill for any Python programmer, as it allows for efficient text processing and analysis. We will discuss the problem statement and provide solutions using different approaches in Python. Using the split() Method Syntax string.split(separator, maxsplit) The split() method takes two optional parameters: separator and maxsplit. By default, the separator is any whitespace, and maxsplit is −1, which means the method will split the string at every occurrence of ... Read More

Check if there are T number of Continuous of Blocks of 0s or not in given Binary Matrix

Pranavnath
Updated on 09-Aug-2023 15:24:04

84 Views

Introduction Binary matrices are widely used in computer science and various fields to represent data or solve complex problems efficiently. In some cases, it becomes important to identify whether a given binary matrix contains continuous blocks of zeros. In this article, we will explore an elegant solution using C++ code that allows us to detect if there are T number of continuous blocks of zeroes within a given binary matrix. This approach is both intuitive and efficient, making it suitable for practical implementation. Check if there are T number of continuous of blocks of 0s or not Given ... Read More

Count of Root to Leaf Paths Consisting of at most M Consecutive Nodes having Value K

Pranavnath
Updated on 09-Aug-2023 15:15:25

91 Views

Introduction Binary trees are fascinating data structures that have numerous applications in computer science and programming. One interesting problem is finding the count from the given tree composed of a parent along with its child nodes. The Binary tree is composed of nodes and the root node is decided and from which the child nodes can be given according the user need. The K value is decided and the way it traverses is chosen by the M value. Count of Root to Leaf Paths The graph is created with various nodes holding the values in form of ... Read More

Show Pearson Correlation Test Between Two Variables using Python

Vishal Gupta
Updated on 29-Sep-2023 14:54:46

206 Views

The Pearson Correlation Test is a simple statistical method in Python that measures the relationship between two parameter variables. It is useful to measure the relationship between two variables graphically, so you can know how strong the relationship is between the variables and whether they are related or not. To find Pearson Correlation we can use pearsonr() function. Its value falls between -1 and 1, with -1 being a perfect negative correlation, 0 representing no relationship, and 1 representing a perfect positive correlation. Syntax This syntax is used in all the following examples. pearsonr(variable1, variable2) Algorithm Step ... Read More

Pie Syntax (@) in Python

Vishal Gupta
Updated on 29-Sep-2023 14:33:09

178 Views

The Pi method or Pi Syntax is used to decorate a function or method in Python, and is known as a decorator. The pie method is used to modify the behaviour of a function or method. Pie Syntax (@) can be used by simply placing the @ symbol and the name of the decorator function above the definition of the function. When the function is invoked, Python is instructed to use the decorator. Pie Syntax (@) has the benefit of allowing for more adaptability in function calls. When working with complicated data structures or when you need to put in ... Read More

Phrase extraction in String using Python

Vishal Gupta
Updated on 29-Sep-2023 11:18:53

93 Views

Phrase extraction in Python is the process of identifying meaningful words from a text context. In this, the text is divided into sentences, phrases, words etc. and these phrases are displayed with full meaning. This process is useful in areas such as text analysis, machine learning, and supply-demand identification (information retrieval). Phrase extraction can be used in normal language processing (NLP) tasks to separate phrases from sentences. It can help to recognize words that are known as phrases and can be used for translation, summarising etc. Here we have some method to phrase extraction. Method 1 Using list slicing, enumerate(), ... Read More

Pendulum Module in Python

Vishal Gupta
Updated on 29-Sep-2023 14:28:24

335 Views

The Pendulum Module is used in Python for datetime manipulation and time zone management. Using this module, you can manage date, time, and other related things over time. The Pendulum Module's ability to manage time zones easily is one of its main advantages. It makes it simple to deal with dates and times from all around the world since it can instantly convert between various time zones. The Pendulum Module is a powerful tool for anyone who is dealing with time-sensitive data. You can install this module with following command − pip install pendulum We have some methods in Pendulum ... Read More

Show Pearson type-3 Distribution in Statistics using Python

Vishal Gupta
Updated on 29-Sep-2023 14:44:22

230 Views

The Pearson Type-3 Distribution is a continuous probability distribution that is widely used in statistics. It has a skewed distribution. Three parameters determined the shape of distribution: location, scale, and shape. Discovering this type of distribution would enable statisticians to analyse their data more effectively and make more precise predictions. We can use pearson3.rvs function to generate random numbers from the distribution, and calculate the pdf (probability density function) at a given point with the help of pearson3.pdf function. Parameters of Pearson type-3 distribution Shape parameter − This parameter determines the spread through the probability density of the distribution. ... Read More

Show Pareto Distribution in Statistics using Python

Vishal Gupta
Updated on 29-Sep-2023 11:01:43

559 Views

The Pareto distribution is a type of power-law probability distribution commonly employed to describe measurable phenomena, such as social, scientific, geophysical, or actuarial data. It is named after Vilfredo Pareto, an Italian economist, sociologist, and civil engineer. The Pareto distribution is often used to model the distribution of diverse sets of data, such as city sizes, website traffic, and scientific publication citations. The Pareto principle, known as the 80/20 rule, suggests that 20% of the input contributes to 80% of the outcome in each scenario or system. Python offers various libraries for working with probability distributions, such as the scipy.stats ... Read More

How to pass multiple arguments to a map function in Python?

Vishal Gupta
Updated on 29-Sep-2023 10:50:46

1K+ Views

The map function is an in−built function in Python, which applies a given function to each and every element in an iterable (list, tuple, etc.) and returns an iterator of the result in the list. We can also use multiple arguments in the map function. Syntax This syntax is used in all the following examples − map(function, argument1, argument2, .....) Method 1: Use multiple arguments with map function Example write a program to add two list elements with the help of map function. def add(a, b): return a + b # Create two lists list1 ... Read More

Advertisements