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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Finding Difference between Images using PIL
In image processing, finding the difference between two images is a crucial step in various applications. It is essential to understand the difference between the two images, which can help us in detecting changes, identifying objects, and other related applications. In this tutorial, we will explore how to find the difference between two images using the Python Imaging Library (PIL). Installation To use PIL, we need to install it using the pip package manager − pip install pillow Basic Syntax To find the difference between two images using PIL, we can use the ...
Read MorePython Program to Reverse Every Kth row in a Matrix
In Python, a matrix is a two-dimensional array where all elements have the same data type. Reversing every Kth row means flipping the order of elements in rows at positions K, 2K, 3K, and so on. In this article, we will learn different methods to reverse every Kth row in a matrix using Python. Problem Overview Given a matrix and a value K, we need to reverse the elements in every Kth row. For example, if K=2, we reverse the 2nd, 4th, 6th rows, etc. Input matrix = [[7, 1, 4], [3, 10, 6], ...
Read MorePython Program to find tuple indices from other tuple list
Finding tuple indices from another tuple list is a common task in Python data manipulation. We can use several approaches: dictionary lookup with enumerate(), list comprehension, and the index() method. An ordered and immutable group of objects is referred to as a tuple. Sequences are just what tuples and lists both are. Tuples and lists vary in that tuples cannot be altered, although lists may, and because tuples use parentheses while lists use square brackets. Problem Statement Given an input list containing tuples and another search tuple list, we need to find the indices of the search ...
Read MorePython Program to extract dictionaries with maximum number of keys
Python's implementation of a data structure known more commonly as an associative array is a dictionary. A dictionary is made up of a group of key-value pairs. Each key-value combination corresponds to a key and its corresponding value. In this article, we will learn a python program to extract dictionaries with the maximum number of keys from a list of dictionaries. Problem Overview Given a list containing multiple dictionaries, we need to find and extract the dictionary(ies) that have the maximum number of keys. Example Consider the following input list ? inputList = ...
Read MorePython Program to extract Dictionaries with given Key from a list of dictionaries
Python's implementation of a data structure known more commonly as an associative array is a dictionary. A dictionary is made up of a group of key-value pairs. Each key-value combination corresponds to a key and its corresponding value. In this article, we will learn how to extract dictionaries that contain a specific key from a list of dictionaries using three different approaches. Problem Example Let's understand the problem with an example ? # Input list of dictionaries input_list = [ {'hello': 3, 'tutorialspoint': 6}, {'python': 9}, ...
Read MorePython program to convert URL Parameters to Dictionary items
Python's implementation of a data structure known more commonly as an associative array is a dictionary. A dictionary is made up of key-value pairs, where each key corresponds to its associated value. URL parameters (query strings) often need to be parsed into dictionaries for easier manipulation in web applications. This article demonstrates three different methods to convert URL parameters into Python dictionary items. Methods Overview The following approaches will be covered ? Using urllib.parse.parse_qs() function Using setdefault() and re.findall() functions Using split() function Example Input and Output For all methods, we'll use ...
Read MorePython program to check whether number formed by combining all elements of the array is palindrome
In Python, an array (list) is a collection of comma-separated values enclosed in square brackets. Lists are flexible as their elements don't need to be of the same type. In this article, we will learn how to check whether a number formed by combining all elements of an array is a palindrome ? Methods Used The following are the various methods to accomplish this task ? Using map() & join() functions Using type casting & string concatenation Using str(), list(), extend(), join() and reverse() functions Example Scenario Consider an input list. We ...
Read MorePython Program to Set from dictionary values
In Python, a dictionary is an implementation of a data structure known as an associative array. A dictionary is made up of key-value pairs, where each key maps to its corresponding value. In this article, we will learn how to extract unique values from a dictionary and convert them into a set, which automatically removes duplicates. Example Overview Let's start with an example to understand what we want to achieve ? # Input dictionary with duplicate values input_dict = {'hello': 5, 'tutorialspoint': 10, 'users': 15, 'python': 5} print("Input dictionary:", input_dict) print("Dictionary values:", list(input_dict.values())) # ...
Read MorePython Program to Rotate dictionary by K
Python dictionaries are ordered collections of key-value pairs. Sometimes you need to rotate a dictionary by K positions, which means shifting all key-value pairs by K positions in their order. This article demonstrates how to rotate a dictionary by K positions using two different approaches. Understanding Dictionary Rotation Dictionary rotation shifts all key-value pairs by K positions. For example, rotating {2: 5, 4: 6, 1: 3} by 1 position gives {1: 3, 2: 5, 4: 6}. Example Input and Output # Input dictionary inputDict = {2: 5, 4: 6, 1: 3, 9: 4, 5: 1} ...
Read MorePython Program to Retain first N Elements of a String and Replace the Remaining by K
In this article, we will learn how to retain the first N characters of a string and replace the remaining characters with a specified character K. Python provides several built-in functions like len(), slicing, replace(), and ljust() to accomplish this task efficiently. Problem Overview Given an input string, we need to keep the first N characters unchanged and replace all remaining characters with a replacement character K. Example Let's understand this with a simple example ? # Input input_string = 'tutorialspoint' n = 9 k = "#" # Expected output: 'tutorials#####' print(f"Original: {input_string}") ...
Read More