AmitDiwan has Published 10744 Articles

Python Program to Implement Shell Sort

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 06:08:43

983 Views

When it is required to implement shell sort, a function is defined, and this takes a list and the length of the list as arguments. This list is sorted up to a specific number of elements, wherein the number of elements is the largest value. This is done until the ... Read More

Sort lists in tuple in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 06:07:21

359 Views

When it is required to sort the lists in a tuple, the 'tuple' method, the 'sorted' method and a generator expression can be used.The 'sorted' method is used to sort the elements of a list. It is a built-in function, that returns the sorted list.Generator is a simple way of ... Read More

Custom sorting in list of tuples in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 06:05:31

798 Views

When it is required to sort the list of tuples in a customized manner, the 'sort' method can be used.The 'sort' method sorts the elements of the iterable in a specific order, i.e ascending or descending. It sorts the iterable in-place.A list can be used to store heterogeneous values (i.e ... Read More

Get tuple element data types in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 06:04:58

851 Views

When it is required to get the tuple element of data types, the 'map' method and the 'type' method can be used.The map function applies a given function/operation to every item in an iterable (such as list, tuple). It returns a list as the result.The 'type' method returns the type ... Read More

Check order specific data type in tuple in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 06:04:02

451 Views

When it is required to check the order of a specific data type in a tuple, the 'isinstance' method and the 'chained if' can be used.The 'isinstance' method checks to see if a given parameter belong to a specific data type or not.The 'chained if' is a chained conditional statement. ... Read More

Convert location coordinates to tuple in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 06:02:34

487 Views

When it is required to convert the location co-ordinates into a tuple format, the 'eval' method can be used.The 'eval' method parses the expression which is passed to it as an argument. It executes that arguments as the code. It returns the result which is evaluated from the 'expression', i.e ... Read More

Remove duplicate lists in tuples (Preserving Order) in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 06:02:00

257 Views

When it is required to remove the duplicates present in tuple of list, as well as preserving the order, a list comprehension and the 'set' method can be used.The list comprehension is a shorthand to iterate through the list and perform operations on it.Python comes with a datatype known as ... Read More

Intersection in Tuple Records Data in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:59:14

579 Views

When it is required to find the intersection of data in tuple records, a list comprehension can be used.The list comprehension is a shorthand to iterate through the list and perform operations on it.A list can be used to store heterogeneous values (i.e data of any data type like integer, ... Read More

Check if tuple and list are identical in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:57:05

333 Views

When it is required to check if a tuple and a list are identical, i.e they contain same elements, a simple loop can be used.A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).Below is a demonstration ... Read More

Common words among tuple strings in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:56:13

326 Views

When it is required to find common words among the tuple strings, the 'join' method, the 'set' method, the '&' operator and the 'split' method is used.The 'join' method can be used to join multiple values based on a specific value, Python comes with a datatype known as 'set'. This ... Read More

Advertisements