Arnab Chakraborty has Published 4173 Articles

Program to find elements from list which have occurred at least k times in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:57:30

359 Views

Suppose we have a list of elements called nums, and a value k. We have to find those elements which have occurred at least k number of times.So, if the input is like nums = [2, 5, 6, 2, 6, 1, 3, 6, 3, 8, 2, 5, 9, 3, 5, ... Read More

Python program to find product of rational numbers using reduce function

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:56:49

537 Views

Suppose we have a list of rational numbers. We have to find their product using reduce function. The reduce() function applies a function with two arguments cumulatively on a list of objects from left to right.So, if the input is like fractions = [(5, 3), (2, 8), (6, 9), (5, ... Read More

Python program to validate email address

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:53:41

15K+ Views

Suppose we have an email address as string. We have to check whether this is valid or not based on the following conditions −The format must be username@company.domain formatUsername can only contain upper and lowercase letters, numbers, dashes and underscoresCompany name can only contain upper and lowercase letters and numbersDomain ... Read More

Program to find number of ways we can get a number which is sum of nth power of unique numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:51:42

359 Views

Suppose we have a number x and another number n. We have to find number of ways we can get x as sum of nth power of some unique numbers.So, if the input is like x = 100 n = 2, then the output will be 3 because possible solutions ... Read More

Python program to sort string in custom order

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:51:07

970 Views

Suppose we have one alphanumeric string s. We have to sort it based on following conditionAll sorted lowercase letters will be placed before uppercase letters.All sorted uppercase letters will be placed before digits.All sorted odd digits will be placed before sorted even digits.So, if the input is like s = ... Read More

Python program to sort table based on given attribute index

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:47:21

451 Views

Suppose we have a 2d list containing information about athletes. This information is rank, age, height. Each row contains information for different athletes. We also have another number k. We have to sort the data based on kth attribute.So, if the input is likeRankageheight125190235180333185426175535180And k = 1.then the output will ... Read More

Python program to define class for complex number objects

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:44:06

5K+ Views

Suppose we want to do complex number tasks by defining a complex number class with following operations −add() to add two complex numberssub() to subtract two complex numbersmul() to multiply two complex numbersdiv() to divide two complex numbersmod() to get modulus of complex numbersThe complex numbers will be shown in ... Read More

Program to perform prefix compression from two strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:44:04

373 Views

Suppose we have two strings s and t (both contains lowercase English letters). We have to find a list of pairs of size 3, where each pair is in this form (l, k) here k is a string and l is its length. Now among these three pairs, first one ... Read More

Program to perform string compression in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:40:13

21K+ Views

Suppose we have a string s. We have to compress this string into Run length encoding form. So when a character is repeated k number of times consecutively like 'bbbb' here letter 'b' is repeated four times consecutively, so the encoded form will be 'b4'. For single characters we shall ... Read More

Program to swap string characters pairwise in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:36:40

15K+ Views

Suppose we have a string s. We have to swap all odd positioned elements with the even positioned elements. So finally we shall get a permutation of s where elements are pairwise swapped.So, if the input is like s = "programming", then the output will be "rpgoarmmnig"To solve this, we ... Read More

Advertisements