AmitDiwan has Published 10744 Articles

Python – Remove strings with any non-required character

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:52:58

119 Views

When it is required to remove strings, which have a non-required character, a list comprehension and the ‘any’ operator is used.Below is a demonstration of the same −Example Live Demomy_list = ["python", "is", "fun", "to", "learn"] print("The list is :") print(my_list) my_char_list = ['p', 's', 'l'] print("The character ... Read More

Python – Extract rows with Even length strings

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:51:48

135 Views

When it is required to extract rows with even length strings, a list comprehension along with the ‘all’ operator and ‘%’ operator is used.Below is a demonstration of the same −Example Live Demomy_list = [["python", "is", "best"], ["best", "good", "python"], ["is", "better"], ["for", "coders"]] print("The list is :") print(my_list) ... Read More

Python – Test if Rows have Similar frequency

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:50:50

157 Views

When it is required to check if rows have similar frequency, the ‘all’ operator, the ‘Counter’ method and a simple iteration is used.Below is a demonstration of the same −Example Live Demofrom collections import Counter my_list = [[21, 92, 64, 11, 3], [21, 3, 11, 92, 64], [64, 92, 21, ... Read More

Python Program that filters out non-empty rows of a matrix

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:49:43

193 Views

When it is required to filter out non-empty rows from a matrix, a simple list comprehension along with the ‘len’ method can be used.Below is a demonstration of the same −Example Live Demomy_list = [[21, 52, 4, 74], [], [7, 8, 4, 1], [], []] print("The list is :") print(my_list) ... Read More

Python – Test if all elements are unique in columns of a Matrix

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:47:00

468 Views

When it is required to test if all elements are unique in columns of a matrix, a simple iteration and a list comprehension along with the ‘set’ operator are used.Below is a demonstration of the same −Example Live Demomy_list = [[11, 24, 84], [24, 55, 11], [7, 11, 9]] print("The ... Read More

Python – Remove characters greater than K

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:45:18

173 Views

When it is required to remove characters, which are greater than ‘K’, a simple iteration is used along with the ‘ord’ (Unicode representation) method.Below is a demonstration of the same −Example Live Demomy_list = ["python", "is", "easy", "to", "learn"] print("The list is :") print(my_list) K = 9 print("The value ... Read More

Python – Check if any list element is present in Tuple

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:44:01

913 Views

When it is required to check if any list element is present in a tuple or not, a Boolean value and a simple iteration are used.Below is a demonstration of the same −Example Live Demomy_tuple = (14, 35, 27, 99, 23, 89, 11) print("The tuple is :") print(my_tuple) my_list ... Read More

Python Program to sort rows of a matrix by custom element count

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:42:37

208 Views

When it is required to sort rows of a matrix by custom element count, a method is defined that uses the list comprehension and ‘len’ method to find the output.Below is a demonstration of the same −Example Live Demodef get_count_matrix(my_key):    return len([element for element in my_key if element in custom_list]) ... Read More

Python Program to Filter Rows with a specific Pair Sum

AmitDiwan

AmitDiwan

Updated on 04-Sep-2021 10:40:49

214 Views

When it is required to filter rows with a specific pair sum, a method is defined. It checks to see if elements in a specific index is equal to key, and returns output based on this.Below is a demonstration of the same −Example Live Demodef find_sum_pair(val, key):    for index ... Read More

Difference Between Top-down and bottom-up Integration Testing

AmitDiwan

AmitDiwan

Updated on 29-Apr-2021 09:10:48

2K+ Views

In this post, we will understand the difference between top-down integration testing and bottom-up integration testing −Top-down Integration TestingIt is also known as incremental integration testing.The higher level modules are first tested after which the lower level modules are tested.Once it is done, they are integrated.The higher level modules are ... Read More

Advertisements