Sunday, 23 January 2022

Write a Python program to compute element-wise sum of given tuples.

Slip 11 Q 1

CODE:

Original lists: (1, 2, 3, 4) (3, 5, 2, 1) (2, 2, 3, 1) 

Element-wise sum of the said tuples: (6, 9, 8, 6)


x = (1,2,3,4);y = (3,5,2,1);z = (2,2,3,1)

print("Original lists:")
print(x)
print(y)
print(z)

print("\nElement-wise sum of the said tuples:")

result = tuple(map(sum, zip(x, y, z)))
print(result)

OUTPUT :



No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...