Consider the following tuples that store coordinates of a geometric figure each.  Write a python code to generate a new tuple containing coordinates obtained by adding the corresponding coordinates of both the figures.  

tup1 = ((1,3),(4,5),(2,9),(1, 10)) 


# Define the tuples tup1 and tup2 that store the coordinates of two geometric figures

tup1 = ((1,3),(4,5),(2,9),(1, 10))

tup2 = ((6,7),(3,9),(1,1),(7,3))

# Initialize an empty tuple to store the coordinates of the new figure

tup3 = ()

# Use a for loop to iterate over the indices of the tuples

for i in range(len(tup1)):

    # Use the + operator to add the corresponding coordinates of tup1 and tup2 and create a new tuple

    coord = (tup1[i][0] + tup2[i][0], tup1[i][1] + tup2[i][1])

    # Use the + operator to append the new tuple to tup3

    tup3 = tup3 + (coord,)

# Print the value of tup3 using the print() function

print("The new tuple containing the coordinates of the new figure is", tup3)

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.