Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 150 of 2547
Python Program to Convert Singular to Plural
In this article, we will learn a Python Program to Convert Singular to Plural using various methods and libraries. Converting singular words to plural forms is a common task in natural language processing. While basic rules like adding 's' work for many words, English has complex pluralization rules that require more sophisticated approaches. Methods Used The following are the various methods to accomplish this task − Using the regex module Using NLTK and Pattern-en Packages Using the TextBlob module Using inflect module ...
Read MorePython Program to check Involutory Matrix
In this article, we will learn a Python program to check whether a matrix is an Involutory Matrix. An involutory matrix is a special type of square matrix that is its own inverse. What is an Involutory Matrix? An involutory matrix is a square matrix that, when multiplied by itself, gives the identity matrix. In mathematical terms, if A * A = I, then matrix A is called an involutory matrix, where I represents the Identity matrix. Matrix A: 1 ...
Read MorePython Program for Number of local extrema in an array
In this article, we will learn a Python program to find the number of local extrema in an array. A local extrema is an element that is either a local maximum (greater than both neighbors) or a local minimum (less than both neighbors). The first and last elements cannot be extrema since they don't have two neighbors. What are Local Extrema? Consider an array element at position i. It is a local extrema if: Local Maximum: array[i] > array[i-1] and array[i] > array[i+1] Local Minimum: array[i] < array[i-1] and array[i] < array[i+1] ...
Read MoreAdditive Secret Sharing and Share Proactivization ñ Using Python
Additive Secret Sharing and Share Proactivization are cryptographic techniques to share a password or other confidential data among a group of people. In this article, we will explain these techniques and implement Python code to demonstrate them. Additive Secret Sharing Additive secret sharing is a technique used in cryptography to share a secret string or a password among multiple parties, such that all of the parties must collaborate to reconstruct the secret. For example ? Original Secret Key: 1234 Generated five Shares: [-488, -55, -417, -720, 2914] Reconstructed Secret: 1234 Explanation: The original secret ...
Read MoreMatrix and linear Algebra calculations in Python
In this article, we will learn Matrix and linear Algebra calculations in Python such as matrix multiplication, finding determinants, solving linear equations, etc. A matrix object from the NumPy library can be used for this. When it comes to calculation, matrices are relatively comparable to the array objects. Linear Algebra is a huge topic, however, NumPy is an excellent library to start if you need to manipulate matrices and vectors. Operations Covered Finding Transpose of a Matrix Using Numpy Finding Inverse of a Matrix Using Numpy ...
Read MorePython Program to Test if any set element exists in List
In this article, we will learn how to check if any set element exists in a list using three different Python methods. Methods Used Using any() function Using bitwise & operator Using Counter(), filter() and lambda functions Example Problem We have an input set and input list. We need to check whether any element from the set exists in the list ? Input inputSet = {4, 8, 1, 3, 5, 7} inputList = [7, 15, 20] Expected Output Checking whether any set element present in the input ...
Read MorePython Program to Subtract K from each digit
In this article, we will learn how to write a Python program that subtracts a given value K from each digit of numbers in a list. When the result becomes negative, we use 0 instead. Given an input list containing numbers and a K value, we subtract K from each individual digit and return the modified numbers. Example Let's understand with an example ? Input list = [1034, 356, 2145, 6712, 8671] K value = 3 For the number 1034, we subtract 3 from each digit: 1 − 3 = −2 ...
Read MorePython Program to Split a String by Custom Lengths
In this article, we will learn how to split a string by custom lengths in Python. This technique is useful when you need to break a string into segments of specific sizes, such as parsing fixed-width data formats or creating chunks for processing. Methods Used The following are the various methods to accomplish this task − Using for loop and slicing Using List Comprehension with iter() and next() functions Problem Overview Let's understand the problem with an example. Assume we have an input string and custom lengths ...
Read MorePython Program to Sort A List Of Names By Last Name
In this article, we will learn how to sort a list of names by last name using Python. This is a common task when working with name data that needs alphabetical ordering by surname. Methods Used Using lambda with sorted() function Using lambda with sort() method Example Overview Let's assume we have a list containing full names as strings. We need to sort these names alphabetically by their last names ? Input names = ['sachin tendulkar', 'suresh raina', 'hardik pandya'] Expected Output ['hardik pandya', 'suresh raina', 'sachin tendulkar'] ...
Read MorePython Program to Replace all words except the given word
In this article, we will learn how to replace all words except the given word in a string in Python. This technique is useful for text processing where you want to mask certain words while preserving specific keywords. Methods Used The following are the various methods to accomplish this task: Using For Loop, split() & join() Functions Using List Comprehension Problem Statement Given an input string, we need to replace all words with a replacement character except for one specific word that should remain unchanged. Input ...
Read More