Predict the output  

T1=(10,20,30,40,50) 
T2=(100,200,300) 
T3=T1+T2 
print T3 
print T2+T1 

 

Answer:

The output of the code is:

(10, 20, 30, 40, 50, 100, 200, 300)

(100, 200, 300, 10, 20, 30, 40, 50)

Explanation:

  • The code creates two tuples, T1 and T2, with different elements.
  • The code then uses the + operator to concatenate (join) the two tuples and assign the result to a new variable T3.
  • The code then prints the value of T3 using the print() function. The print() function displays the output to the standard output device (usually the screen).
  • The code then prints the value of T2 + T1 using the print() function. This is equivalent to concatenating T2 and T1 in reverse order and displaying the output.
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.