
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
199 Views
When it is required to sort matrix by maximum row element, a method is defined that takes one parameter and uses ‘max’ method to determine the result.ExampleBelow is a demonstration of the same −def sort_max(row): return max(row) my_list = [[15, 27, 18], [39, 20, 13], [13, 15, 56], ... Read More

AmitDiwan
195 Views
When it is required to display the key of list value with maximum range, a simple iteration is used.ExampleBelow is a demonstration of the same −my_dict = {"pyt" : [26, 12, 34, 21], "fun" : [41, 27, 43, 53, 18], "learning" : [21, 30, 29, 13]} print("The dictionary is ... Read More

AmitDiwan
441 Views
When it is required to find the occurrences for each value of a particular key, a list comprehension and the lambda method is used.Below is a demonstration of the same −Examplefrom itertools import groupby my_dict = [{'pyt' : 13, 'fun' : 44}, {'pyt' : 63, 'best' : 15}, {'pyt' : ... Read More

AmitDiwan
307 Views
When it is required to extract mono-digit elements, list comprehension and the ‘all operator are used.Below is a demonstration of the same −Examplemy_list = [863, 1, 463, "pyt", 782, 241, "is", 639, 4, "fun"] print("The list is :") print(my_list) my_result = [index for index in my_list if all(str(element) ... Read More

AmitDiwan
199 Views
When it is required to sort dictionaries by size, a method is defined that takes one parameter and uses ‘len’ to determine the output.Below is a demonstration of the same −Exampledef get_len(element): return len(element) my_dict = [{24: 56, 29: 11, 10: 22, 42: 28}, {54: 73, 59: 11}, ... Read More

AmitDiwan
242 Views
When it is required to display cross pattern pairs in list, a list comprehension and the ‘*’ operator are used.Below is a demonstration of the same −Examplemy_list_1 = [14, 35, 26] my_list_2 = [36, 24, 12] print("The first list is :") print(my_list_1) print("The second list is :") print(my_list_2) ... Read More

AmitDiwan
285 Views
When it is required to display nearest occurrence between two elements in a list, a method is defined that takes three parameters. It uses the ‘not in’ operator, and the list comprehension to determine the result.Below is a demonstration of the same −Exampledef nearest_occurence_list(my_list, x, y): if x not ... Read More

AmitDiwan
191 Views
When it is required to filter tuple with integers, a simple iteration and the ‘not’ operator and the ‘isinstance’ method is used.ExampleBelow is a demonstration of the same −my_tuple = [(14, 25, "Python"), (5, 6), (3, ), ("cool", )] print("The tuple is :") print(my_tuple) my_result = [] for ... Read More

AmitDiwan
267 Views
When it is required to extract tuples with elements in a given range, the filter and lambda methods are used.ExampleBelow is a demonstration of the same −my_list = [(13, 15, 17), (25, 56), (13, 21, 19 ), (44, 14)] print("The list is :") print(my_list) beg, end = 13, 22 my_result = list(filter(lambda sub : all(element >= beg and element

AmitDiwan
305 Views
When it is required to extract ‘K’th element of every ‘N’th tuple in a list, a simple iteration and the ‘append’ method is used.ExampleBelow is a demonstration of the same −my_list = [(54, 51, 23), (73, 24, 47), (24, 33, 72), (64, 27, 18), (63, 24, 67), (12, 25, 77), ... Read More