Python Articles

Page 170 of 855

Python program to find Sum of a sublist

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 3K+ Views

In this article, we will learn different methods to find the sum of a sublist in Python. A sublist is a contiguous portion of a list between specified start and end indices. Methods Used The following are the various methods to accomplish this task ? Using For Loop (Brute Force) Using Cumulative Sum Method Using sum() Function Using math.fsum() Function Using For Loop (Brute Force) This method iterates through the sublist elements and adds them one by one ? ...

Read More

Python Program to Convert Singular to Plural

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 5K+ Views

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 More

Python Program to check Involutory Matrix

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 221 Views

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 More

Python Program for Number of local extrema in an array

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 523 Views

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 More

Additive Secret Sharing and Share Proactivization ñ Using Python

Farhan Muhamed
Farhan Muhamed
Updated on 27-Mar-2026 703 Views

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 More

Matrix and linear Algebra calculations in Python

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 1K+ Views

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 More

Python Program to Test if any set element exists in List

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 3K+ Views

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 More

Python Program to Subtract K from each digit

Ranbir Kapoor
Ranbir Kapoor
Updated on 27-Mar-2026 194 Views

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 More

Python Program to Split a String by Custom Lengths

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 3K+ Views

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 More

Python Program to Sort A List Of Names By Last Name

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 2K+ Views

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 More
Showing 1691–1700 of 8,549 articles
« Prev 1 168 169 170 171 172 855 Next »
Advertisements