What will be the output of the following code?

tup1 =(3,4),
res = tup1+tup2
print(“ new tuple is "+ str(res))



Tuple concatenation - Example - Teachoo (2).png

The output of the code is:  new tuple is ((3, 4), (5, 6))


  • The code creates two tuples, tup1 and tup2 , with two elements each.
  • The code then uses the + operator to concatenate (join) the two tuples and assign the result to a new variable res.
  • The + operator creates a new tuple that contains all the elements of the first tuple followed by all the elements of the second tuple.
  • The code then prints the value of res using the str() function to convert it to a string and concatenating it with another string "new tuple is ".
  • The print() function displays the output to the standard output device (usually the screen).
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.