Aditya Varma

Aditya Varma

31 Articles Published

Articles by Aditya Varma

Page 2 of 4

Python Program to Find Numbers in Range and not in Set

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 528 Views

In Python, we can find numbers that exist within a specific range but are not present in a given set using several approaches: the not operator, set subtraction, or the Counter function. A Python set is a collection of unordered, unique elements. Sets are mutable, meaning you can add or remove elements after creation, but the elements themselves must be immutable and distinct. Problem Example Given an input set and a range, find all numbers in the range that don't exist in the set ? Input input_set = {3, 10, 2, 11, 15, 4, ...

Read More

Python Program to Extract Keys with specific Value Type

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 252 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 how to extract keys with specific value type in Python using three different approaches. Methods Used The following are the various methods to accomplish this task − Using for loop and isinstance() method Using list comprehension and isinstance() method Using keys() & type() methods Problem Example Let's consider ...

Read More

Python Program to Expand Character Frequency String

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 516 Views

A character frequency string contains characters followed by their frequency count. For example, 'p5y3t6' means 'p' appears 5 times, 'y' appears 3 times, and 't' appears 6 times. Expanding this string produces 'pppppyyytttttt'. In this article, we will learn how to expand character frequency strings using different Python approaches. Problem Statement Given an input string where characters alternate with their frequencies, expand each character according to its frequency count ? Example inputString = 'p5y3t6h2o1n4' print("Input:", inputString) print("Expected Output: pppppyyytttttthhonnnn") Input: p5y3t6h2o1n4 Expected Output: pppppyyytttttthhonnnn Method 1: Using zip() and ...

Read More

Python Program to Concatenate all keys which have similar values

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 188 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 how to concatenate all keys which have similar values in Python ? Methods Used The following are the various methods to accomplish this task: Using defaultdict() and join() functions Using dictionary comprehension, groupby() and join() functions Example Assume we have taken an input dictionary. We will now concatenate ...

Read More

Python Program to Add K between case shifts

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 163 Views

In Python, we can add a symbol between case shifts (transitions from uppercase to lowercase or vice versa) using built-in string methods like isupper(), islower(), and join(). A case shift occurs when consecutive characters change from uppercase to lowercase or lowercase to uppercase. Understanding Case Shifts Let's see what case shifts look like with an example ? # Example of case shifts in a string text = "tUtoRialsPoInt" print("Original string:", text) print("Case shifts occur between:") print("t -> U (lowercase to uppercase)") print("U -> t (uppercase to lowercase)") print("o -> R (lowercase to uppercase)") ...

Read More

Print all repeating digits present in a given number in sorted order

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 877 Views

Finding repeating digits in a number is a common programming task. Python provides several built-in functions like count(), Counter(), and operator.countOf() that can efficiently identify and sort duplicate digits. Problem Statement Given a number, we need to find all digits that appear more than once and display them in sorted order. Input inputNum = 5322789124199 Expected Output 1 2 9 In the input number 5322789124199, digits 1, 2, and 9 appear multiple times, so they are displayed in ascending order. Method 1: Using count() Function The count() method returns ...

Read More

Python Program to Increment Numeric Strings by K

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 937 Views

A numeric string in Python is a string that represents a numerical value using digits, signs, and decimal points, allowing for mathematical operations and data processing. In this article, we will learn different methods to increment numeric strings by K while keeping non-numeric strings unchanged. Problem Overview Given a list of strings containing both numeric and non-numeric values, we need to increment only the numeric strings by a given value K ? Example Input: input_list = ["10", "hello", "8", "tutorialspoint", "12", "20"] k = 5 Expected Output: ['15', 'hello', '13', ...

Read More

Python Program to find the key of Maximum Value Tuples in a Dictionary

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 337 Views

Finding the key of the maximum value tuples in a Python dictionary means identifying the key associated with the tuple that has the highest value among all the tuples in the dictionary. This is useful for retrieving the most significant or relevant information from the data. Problem Statement Given a dictionary with tuples as values, we need to find the key corresponding to the tuple with the maximum value (typically the second element of the tuple). Example Input: inputDict = {'hello': ("p", 2), 'tutorialspoint': ("c", 15), 'python': ("k", 8)} print("Input dictionary:", inputDict) ...

Read More

Python Program to find Maximum Scoring Word

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 289 Views

In Python, finding the maximum scoring word involves calculating scores for each word based on character positions in the alphabet. A character's score equals its position (a=1, b=2, c=3, etc.), and the word with the highest total score wins. Problem Understanding Given an input string, we need to find the word with the maximum score where each character contributes its alphabetical position value ? Input input_string = "hello tutorialspoint python users and learners" print("Input string:", input_string) Input string: hello tutorialspoint python users and learners In this example, "tutorialspoint" has the highest ...

Read More

Python Program to Convert list of Dictionaries to Dictionary of Lists

Aditya Varma
Aditya Varma
Updated on 27-Mar-2026 758 Views

In Python, a dictionary is a built-in data structure that stores data in key-value pairs. It allows efficient retrieval and modification of values based on their corresponding keys. Each key in a dictionary must be unique, and it is associated with a specific value. A dictionary of lists is a dictionary where the values associated with each key are lists. This means that each key maps to multiple values, and those values are stored as elements within a list. On the other hand, a list of dictionaries is a list that contains multiple dictionaries as its elements. Each ...

Read More
Showing 11–20 of 31 articles
Advertisements