AmitDiwan has Published 10744 Articles

Python – Extract Percentages from String

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:27:44

436 Views

When it is required to extract the percentages from a string, the regular expressions and the ‘findall’ method of the package is used.ExampleBelow is a demonstration of the same −import re my_string = 'Python is % always fun % to learn % and teach' print("The list is : ... Read More

Python – Filter all uppercase characters from given list of tuples

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:26:19

644 Views

When it is required to filter all the uppercase characters from a list of tuples, a simple iteration, a Boolean value, the ‘append’ method and the ‘isupper’ methods are used.ExampleBelow is a demonstration of the same −my_list = [("PYTHON", "IS", "Fun"), ("PYTHON", "COOl"), ("PYTHON", ), "ORIENTED", "OBJECT"] print("The list ... Read More

Python program to remove elements at Indices in List

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:24:11

232 Views

When it is required to remove the elements at indices in a list, the ‘enumerate’ attribute, the ‘not in’ operator, a simple iteration and the ‘append’ methods are used.ExampleBelow is a demonstration of the same −my_list = [91, 75, 15, 45, 69, 78, 23, 71, 36, 72] print("The list ... Read More

Python – Filter tuple with all same elements

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:22:26

221 Views

When it is required to filter out the tuple that contains same elements, a list comprehension and the ‘set’ operator and the ‘len’ methods can be used.ExampleBelow is a demonstration of the same −my_list = [(31, 54, 45, 11, 99) , (11, 11), (45, 45, 45), (31, 54, 45, 11, ... Read More

Python – Convert Rear column of a Multi-sized Matrix

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:20:43

98 Views

When it is required to convert the rear column of a multi-sized matrix, a simple iteration and the ‘append’ method along with negative indexing is used.ExampleBelow is a demonstration of the same −my_list = [[41, 65, 25], [45, 89], [12, 65, 75, 36, 58], [49, 12, 36, 98], [47, 69, ... Read More

Python – Maximum of K element in other list

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:17:28

194 Views

When it is required to get the maximum of K elements based on another list, a simple iteration, the ‘append’ method and the ‘max’ methods are used.ExampleBelow is a demonstration of the same −my_list_1 = [62, 25, 32, 98, 75, 12, 46, 53] my_list_2 = [91, 42, 48, 76, 23, ... Read More

Python – Split Numeric String into K digit integers

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:15:05

361 Views

When it is required to split a numeric string into K digit integers, a simple iteration, the ‘int’ method and the ‘append’ methods are used.ExampleBelow is a demonstration of the same −my_string = '69426874124863145' print("The string is : " ) print(my_string) K = 4 print("The value of K ... Read More

Python – Check if elements in a specific index are equal for list elements

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:13:09

793 Views

When it is required to check if the elements in a specific index are equal to another list of elements, a simple iteration and a Boolean value are used.ExampleBelow is a demonstration of the same −my_list_1 = [69, 96, 23, 57, 13, 75, 13] my_list_2 = [68, 21, 69, 23, ... Read More

Python – Strings with all given List characters

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:08:40

371 Views

When it is required to find the strings which have all the given characters present in a list, a method is defined that takes the string as a parameter and iterates through the string, and adds the index value to it.ExampleBelow is a demonstration of the same −print("Method definition begins...") ... Read More

Python – Filter consecutive elements Tuples

AmitDiwan

AmitDiwan

Updated on 13-Sep-2021 11:06:53

279 Views

When it is required to filter consecutive elements from a list of tuple, a method is defined that takes a list of tuple as a parameter and checks the index of every tuple, and returns a Boolean value depending on the index.ExampleBelow is a demonstration of the same −print("Method definition ... Read More

Advertisements