
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
600 Views
When it is required to find tuples that have position elements from a list of tuples, list comprehension can be used.Below is a demonstration of the same −Example Live Demomy_list = [(56, 43), (-31, 21, 23), (51, -65, 26), (24, 56)] print("The list is : ") print(my_list) my_result = ... Read More

AmitDiwan
889 Views
When it is required to find tuples that have elements that are divisible by a specific element ‘K’, the list comprehension can be used.Below is a demonstration of the same −Example Live Demomy_list = [(45, 90, 135), (71, 92, 26), (2, 67, 98)] print("The list is : ") print(my_list) ... Read More

AmitDiwan
307 Views
When it is required to sort the tuples based on the maximum element in it, a method is defined that uses the ‘max’ method to return the highest element.Next the ‘sort’ method can be used to sort the list based on the previously defined function.Below is a demonstration of the ... Read More

AmitDiwan
195 Views
When it is required to find the consecutive column difference in a list of tuple, it can be iterated over, and the ‘abs’ method and the ‘append’ method can be used.The ‘abs’ method returns the absolute or positive value, and the append adds elements to a list.Below is a demonstration ... Read More

AmitDiwan
365 Views
When it is required to remove tuples from a list of tuples where a ‘None’ element is present, a list comprehension can be used.Below is a demonstration of the same −Example Live Demomy_list = [(2, None, 12), (None, None, None), (23, 64), (121, 13), (None, ), (None, 45, 6)] print("The ... Read More

AmitDiwan
213 Views
When it is required to trim a list of tuples by a specific number of elements, the ‘del’ operator can be used.Below is a demonstration of the same −Example Live Demomy_list = [(1, 2, 11), (99, 76, 34, 89), (3.08, 11.56), ("Hi", "Will"), ("Rob", 'Ron')] n = 2 print("The list is ... Read More

AmitDiwan
617 Views
When it is required to find the number of times every day of the week occurs in a year, a list is defined, and it is iterated over, and is count is incremented respectively.Below is a demonstration of the same −Example Live Demoimport math def num_of_occurrence( n, firstday): my_days ... Read More

AmitDiwan
1K+ Views
When it is required to convert a string into a timestamp, the ‘mktime’ method is used. This method is present in the ‘time’ package.Below is a demonstration of the same −Example Live Demoimport time import datetime my_string = "24/03/2021" print("The date string is :") print(my_string) print("The timestamp is :") print(time.mktime(datetime.datetime.strptime(my_string, ... Read More

AmitDiwan
600 Views
When it is required to create a lap timer using Python, the ‘time’ method is used. The number of laps is predefined, and a try catch block is defined, to start the lap timer.Below is a demonstration of the same −Example Live Demoimport time start_time=time.time() end_time=start_time lap_num=1 print("Click on ... Read More

AmitDiwan
397 Views
When it is required to find the difference between the current time and a given time, a method can be defined, that takes the hours, minutes, and seconds as parameter. It then calculates the difference between two given times.Below is a demonstration of the same −Example Live Demodef difference_time(h_1, m_1, h_2, ... Read More