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

Hits: 6 (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 …

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

Hits: 3 (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 …

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

Hits: 1 (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] …

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

Hits: 1 (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 …

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

Hits: 2 (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 …