Arnab Chakraborty has Published 4173 Articles

Python program to validate string has few selected type of characters or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:01:37

156 Views

Suppose we have a string s. We have to check whether the string contains the following or not.NumbersLowercase lettersUppercase lettersNote − There may be some other symbols, but these three must be thereSo, if the input is like s = "p25KDs", then the output will be TrueTo solve this, we ... Read More

Python program to change character of a string using given index

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 10:55:39

428 Views

Suppose we have a string s, an index i and a character c. We have to replace the ith character of s using c. Now in Python, strings are immutable in nature. We cannot write a statement like s[i] = c, it will raise an error [TypeError: 'str' object does ... Read More

Python program to split a string and join with comma

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 10:31:58

1K+ Views

Suppose we have few words that are separated by spaces. We have to split these words to form a list, then join them into a string by placing comma in-between.So, if the input is like s = "Programming Python Language Easy Funny", then the output will be Programming, Python, Language, ... Read More

Python program to find hash from a given tuple

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 10:26:56

6K+ Views

Suppose we have a tuple. There are few numbers are present. We have to find the hash value of this tuple by using hash() function. This is a built-in function. The hash() function can work on some datatypes like int, float, string, tuples etc, but some types like lists are ... Read More

Python program to sort and reverse a given list

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 10:22:32

1K+ Views

Suppose we have a list of numbers in Python. We have to reverse and sort the lists using list operations but do not change the actual list. To reverse the list we have reverse() function for lists but if we use it, the list will be reversed in place. Similar ... Read More

Python program to find average score of each students from dictionary of scores

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 10:20:43

9K+ Views

Suppose we have a dictionary of students marks. The keys are names and the marks are list of numbers. We have to find the average of each students.So, if the input is like scores = {'Amal' : [25, 36, 47, 45], 'Bimal' : [85, 74, 69, 47], 'Tarun' : [65, ... Read More

Program to find expected sum of subarrays of a given array by performing some operations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 09:30:51

412 Views

Program to find expected sum of subarrays of a given array by performing some operationsSuppose we have an array A whose size is n and two values p and q. We can perform these operations on A.Randomly select two indexes (l, r) where l < r, then exchange A[l] and ... Read More

Python program to display all second lowest grade student name from nested list

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 09:28:02

2K+ Views

Suppose we have the names and grades for each student in a nested list we have to display the names of any students having the second lowest grade. If there are more than one students with the second lowest grade, reorder these in an alphabetical order and print each name ... Read More

Python program to find runner-up score

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 09:21:47

2K+ Views

Suppose we have a list of scores for different number of participants. We have to find the runner-up score.So, if the input is like scores = [5, 8, 2, 6, 8, 5, 8, 7], then the output will be 7 because the winner score is 8 and second largest score ... Read More

Program to find expected value of maximum occurred frequency values of expression results in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 09:20:44

175 Views

Suppose we have M different expressions, and the answers of these expressions are in range 1 to N (both inclusive) So consider x = max(f(i)) for each i in range 1 through N, we have to find the expected value of x.So, if the input is like M = 3, ... Read More

Advertisements