Expected Value Binomial Distribution Central Limit Theorem Confidence Interval
About Us Contact Us Terms of Service Privacy Policy DMCA Policy
Python Programming - Lists and Strings

Python Practice Questions

Lists and Stings Practice Questions

Q1. Given two list of numbers as follows:

list1 = [10, 20, 23, 11, 17]
list 2 = [13, 43, 24, 36, 12]

Write a program in python to create a new list such that the new list would contain only odd numbers from the first list and even numbers from the second list.

Sample output: [23, 11, 17, 24, 36, 12]

Q2. Write a python program to extract each digit from an integer and print it in the reverse order
For example, If the given int is 7536, then the output should be “6 3 5 7“, with a space separating the digits.
Try using loops and without using loop as well.

Q3. Write a python program to concatenate two lists index wise.
Example input:

list1 = ["M", "na", "i", "Ke"] list2 = ["y", "me", "s", "lly"]

Sample output:
['My', 'name', 'is', 'Kelly']

Q4. Write a python program to remove empty strings from the list of strings
Example input:
list1 = ["Mike", "", "Emma", "Kelly", "", "Brad"]
Output: ["Mike", "Emma", "Kelly", "Brad"]

Q5. Given a nested list, Write a python program to extend it by adding the sub list ["h", "i", "j"] in such a way that it will look like the following list.
Input list:
list1 = ["a", "b", ["c", ["d", "e", ["f", "g"], "k"], "l"], "m", "n"]

Output list:
['a', 'b', ['c', ['d', 'e', ['f', 'g', 'h', 'i', 'j'], 'k'], 'l'], 'm', 'n']

Q6. Given an input string with the combination of the lower and upper case letters. Write a python program to arrange the characters in such a way that all lowercase letters should come first.
Sample input:
str1 = "hStAtistiCS"
Sample Output:
str2 = "httistiSACS"

Q7. Given two input strings s1 and s2. Write a python program to check if all the characters of s1 are present in s2 or not. Print True if all characters are present, otherwise print false.
Sample Input:
s1 = "logy"
s2 = "I love Python programming language"
Sample Output:

© Copyright www.hstatistics.com