Example:
tuple = ("python", "includehelp", 43, 54.23)
Division Operation on Tuples
In this program, we are given two tuples. We need to create a python program to return a tuple that contains the division of elements of the two tuples.
Input:
tuple1 = (4, 25, 7, 9) , tuple2 = (2, 5, 4, 3)
Output:
(2, 5, 1, 3)
Method 1:
One method to perform the XOR operation on elements of tuples is by using generator expression with the zip() to map the elements of both tuples using the division operation and create a tuple with resultant values.
Output:
Method 2:
Another method to solve the problem is by mapping the XOR operation of the tuple elements done using the floordiv() method from the operator library. Then convert the map to a tuple using the tuple() method.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer