This program defines two tuples tup1 and tup2, each containing 4 elements. The tuples are then printed to the console. Next, the program uses the map function and a lambda function to perform a bitwise AND operation between elements of tup1 and tup2. The map function takes two sequences as arguments (tup1 and tup2) and applies the lambda function element-wise to the corresponding elements in each sequence.
The lambda function takes two arguments i and j and returns the result of a bitwise AND operation between them (i & j). Finally, the result of the map function is passed to the tuple function to convert it to a tuple, which is then stored in the variable res. The string representation of res is then printed to the console with the message " AND operation Between Tuple : ".
tup1 = (10, 4, 6, 9) tup2 = (5, 2, 3, 3) print("Tuple 1 : ",tup1) print("Tuple 2 : ",tup2) res = tuple(map(lambda i, j: i & j, tup1, tup2)) print(" AND operation Between Tuple : ",res)
Tuple 1 : (10, 4, 6, 9) Tuple 2 : (5, 2, 3, 3) AND operation Between Tuple : (0, 0, 2, 1)
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions