What is the difference between the outputs of the code#1 and code#2? Give reasons.
code#1
t1=(1,2,3)
t2=(4,5,6) t3= t1+t2
print( “New tuple is :”=str(t3))
code #2
t1=(1,2,3),
t2=(4,5,6),
t3=t1+t2
print(“New tuple is :”+str(t3))
Answer:
Output of code #1:
New tuple is: (1,2,3,4,5,6)
Output of code #2:
New tuple is ((1,2,3),(4,5,6))
The difference between the outputs of the code #1 and code #2 is that code #1 will print a tuple with six elements, while code #2 will print a tuple with two elements. The reason for this difference is that code #1 uses parentheses without commas to create tuples , while code #2 uses commas with or without parentheses to create tuples.