Day: February 21, 2021

Python Example – Write a Python program to print a long text, convert the string to a list and print all the words and their frequencies

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to print a long text, convert the string to a list and print all the words and their frequencies.   Sample Solution: Python Code : string_words = ”’United States Declaration of Independence From Wikipedia, the free encyclopedia The United States Declaration …

Python Example – Write a Python program to create the combinations of 3 digit combo

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to create the combinations of 3 digit combo.   Sample Solution: Python Code : numbers = [] for num in range(1000): num=str(num).zfill(3) print(num) numbers.append(num) Sample Output: 999   Write a Python program to create the combinations of 3 digit combo Free …

Python Example – Write a Python program to find unique triplets whose three elements gives the sum of zero from an array of n integers

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to find unique triplets whose three elements gives the sum of zero from an array of n integers.   Sample Solution: Python Code : def three_sum(nums): result = [] nums.sort() for i in range(len(nums)-2): if i> 0 and nums[i] == nums[i-1]: …

Python Example – Write a Python program to remove and print every third number from a list of numbers until the list becomes empty

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to remove and print every third number from a list of numbers until the list becomes empty.   Sample Solution: Python Code : def remove_nums(int_list): position = 3 – 1 idx = 0 len_list = (len(int_list)) while len_list>0: idx = (position+idx)%len_list …

Python Example – Write a Python program to create all possible strings by using vowels

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to create all possible strings by using ‘a’, ‘e’, ‘i’, ‘o’, ‘u’. Use the characters exactly once.   Sample Solution: Python Code : import random char_list = [‘a’,’e’,’i’,’o’,’u’] random.shuffle(char_list) print(”.join(char_list)) Sample Output: iauoe   Write a Python program to create all …