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
Server Side Programming Articles
Page 150 of 2109
Matrix 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 MorePython Program to Remove numbers with repeating digits
In this article, we will learn how to remove numbers with repeating digits from a list in Python. Numbers like 3352 (3 appears twice) or 661 (6 appears twice) will be filtered out, keeping only numbers with unique digits. Problem Example Given an input list of numbers, we need to remove all numbers containing repeating digits ? Input inputList = [3352, 8135, 661, 7893, 99] Expected Output [8135, 7893] In the above example, 3352 has digit 3 repeated twice, 661 has digit 6 repeated, and 99 has digit 9 ...
Read MorePython program to remove K length words in String
In this article, we will learn how to remove all words of a specific length (K) from a string using Python. This is useful for text processing tasks where you need to filter words based on their character count. Problem Statement Given an input string and a value K, we need to remove all words that have exactly K characters and return the modified string. Example inputString = "hello tutorialspoint python codes" k_length = 5 The output will be ? Resultant string after removing 5 length words: tutorialspoint python ...
Read MorePython Program to Remove all digits before given Number
In this article, we will learn how to remove all digits before a given number from a string in Python. This task is useful when processing text data where you need to clean up numeric content selectively. Problem Overview Given an input string containing words and numbers, we want to remove all standalone digits that appear before a specific target number, while keeping the target number and everything after it intact. Example Consider this input ? inputString = 'hello 6 8 10 tutorialspoint 15 python codes' inputNumber = 10 The expected output ...
Read MorePython Program to move numbers to the end of the string
In this article, we will learn different methods to move all numeric digits from their current positions to the end of a string while preserving the order of non-digit characters. Problem Overview Given a string containing letters, digits, and spaces, we need to extract all digits and append them to the end while keeping other characters in their original order. Input inputString = 'hello5691 tutorialspoint1342' Output Resultant string after adding digits at the end: hello tutorialspoint56911342 Here all the numbers 56911342 contained in the input string are moved to the end ...
Read More