Found 27104 Articles for Server Side Programming

Python Program to find tuple indices from other tuple list

Aditya Varma
Updated on 18-Aug-2023 19:41:31

115 Views

To find the tuple indices from other tuple list we can use enumerate function and index function of Python. 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. Example Assume we have taken an input list containing tules and another search tuple list. We will now search the indices of the search tuple list in the given input list Input inputList = [(1, 3), ... Read More

Python program to find Maximum value from dictionary whose key is present in the list

Aditya Varma
Updated on 18-Aug-2023 19:33:29

462 Views

In python we are can use simple for loop and max, count and operator function to find the maximum value from the dictionary whose key is present in the list. 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. Example Assume we have taken an input dictionary and input list. We will now find the maximum value from an input dictionary whose key is also present in the input list. ... Read More

Python Program to extract dictionaries with maximum number of keys

Aditya Varma
Updated on 18-Aug-2023 19:39:29

71 Views

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. Methods Used The following are the various methods to accomplish this task: Using for loop and len() function Using list comprehension and max() function Example Assume we have taken an input list containing multiple dictionaries. We will now extract dictionaries ... Read More

Python Program to extract Dictionaries with given Key from a list of dictionaries

Aditya Varma
Updated on 18-Aug-2023 19:21:33

89 Views

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 a given Key from a list of dictionaries. Methods Used The following are the various methods to accomplish this task: Using list comprehension and keys() function Using filter() and lambda functions Using operator.countOf() method Example Assume we have taken an input list containing dictionaries and an input ... Read More

Python program to convert URL Parameters to Dictionary items

Aditya Varma
Updated on 18-Aug-2023 18:37:44

746 Views

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 convert URL parameters to dictionary items. Methods Used The following are the various methods to accomplish this task − Using urllib.parse.parse_qs() function Using setdefault() and re.findall() functions Using split() function Example Assuming we have taken an input string with URL parameters, we convert this query string to the ... Read More

Python program to check whether number formed by combining all elements of the array is palindrome

Aditya Varma
Updated on 18-Aug-2023 18:49:17

75 Views

In python an array(list) of comma-separated values (items) enclosed in square brackets is one of the most flexible data types available in Python. The fact that a list's elements do not have to be of the same type is important. In this article, we will learn a python program to check whether a number formed by combining all elements of the 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 ... Read More

Python Program to Set from dictionary values

Aditya Varma
Updated on 18-Aug-2023 19:51:09

365 Views

In Python, dictionary is a implementation of a data structure known as an associative array. 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 convert into a Set of dictionary values in python. Methods Used The following are the various methods to accomplish this task: Using generator expression and {} Using values() and set() functions Using Counter() function Example Assume we have taken an input dictionary. We will now extract all the values of a ... Read More

Python Program to Rotate dictionary by K

Aditya Varma
Updated on 18-Aug-2023 19:50:00

135 Views

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. Given a dictionary with some random key-value pairs, In this article, we will learn how to rotate the given dictionary by K in python. Methods Used The following are the various methods to accomplish this task: Using list comprehension, items(), and dictionary comprehension Using dictionary comprehension, deque.rotate(), and items() functions Example Assume we have taken an input dictionary and ... Read More

Python Program to Retain first N Elements of a String and Replace the Remaining by K

Aditya Varma
Updated on 18-Aug-2023 19:54:18

125 Views

In this article we are going to learn how to use internla python functions like len(), slicing(), replace(), ljust() to retain first N element of a string and replace the remaining by k. The python strings are easily made by simply surrounding letters in quotations. Python treats single quotes and double quotes the same way. Assigning a value to a variable and creating a string is really straightforward. Example Assume we have taken an input string N, K values. We will now retain the first N characters of an input string and replace it with the given K character ... Read More

Python Program to Replace occurrences by K except first character

Aditya Varma
Updated on 18-Aug-2023 19:53:02

308 Views

Python has in build functions like slicing() and replace() that can be used for replacing the occurrence by k except the first character. In Python, strings are among the most often used types. These are easily made by simply surrounding letters in quotations. Python treats single quotes and double quotes the same way. Assigning a value to a variable and creating a string is really straightforward. Example Assume we have taken an input string and k. We will now replace all the k characters except the first in an input string with the input character using the above methods. Input ... Read More

Advertisements