AmitDiwan has Published 10744 Articles

Ways to concatenate tuples in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:55:19

6K+ Views

When it is required to concatenate multiple tuples, the '+' operator can be used. A tuple is an immutable data type. It means, values once defined can't be changed by accessing their index elements. If we try to change the elements, it results in an error. They are important contains ... Read More

Remove similar element rows in tuple Matrix in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:53:28

134 Views

When it is required to remove similar element rows in a tuple matrix, the list comprehension and the 'all' method can be used.The list comprehension is a shorthand to iterate through the list and perform operations on it.The 'all' method checks to see if all the values inside an iterable ... Read More

Conversion to N*N tuple matrix in Python

AmitDiwan

AmitDiwan

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

427 Views

When it is required to convert an N*N tuple into a matrix, a simple loop and the * operator can be used.The * operator can be used to get the product of two values. It can also be used to multiple a single value multiple times and display it on ... Read More

Removing duplicates from tuple in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:50:17

1K+ Views

When it is required to remove duplicates from a tuple, the list comprehension is 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).A list of tuple basically contains tuples enclosed in a list.The list comprehension is ... Read More

Record Similar tuple occurrences in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:49:25

106 Views

When it is required to record similar tuple occurrences, the 'map' method, the 'Counter' method and the 'sorted' method 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). A list of tuple basically contains ... Read More

Find Maximum difference between tuple pairs in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:48:49

318 Views

When it is required to find the maximum difference between tuple pairs, the 'max' method and the list comprehension 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). A list of tuple basically contains ... Read More

Repeating tuples N times in Python

AmitDiwan

AmitDiwan

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

3K+ Views

When it is required to repeat a tuple 'N' times, the '*' operator can be used. A tuple is an immutable data type. It means, values once defined can't be changed by accessing their index elements. If we try to change the elements, it results in an error. They are ... Read More

Test if tuple is distinct in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:46:36

1K+ Views

When it is required to test if a tuple has distinct elements in it, the 'set' method and the 'len' method can be used.Python comes with a datatype known as 'set'. This 'set' contains elements that are unique only.The 'len' method gives the length of the parameter passed to it.Below ... Read More

Filter tuples according to list element presence in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:43:40

450 Views

When it is required to filter tuples based on the list element that is present, list comprehension 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).A list of tuple basically contains tuples enclosed in ... Read More

Summation of tuples in list in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:42:48

2K+ Views

When it is required to sum the elements present in a list of tuple, the 'map' method and the 'sum' method 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).A list of tuple basically ... Read More

Advertisements