Computer Science, asked by vedantagrawala2228, 8 months ago

If a is (1,2,3) (a)what is the difference(if any) between a*3 and (a,a,a)

Answers

Answered by apurvvaish2003
13

Answer:a=(1,2,3)

If we do this :

print(a*3) # the result will be (1,2,3,1,2,3,1,2,3)

and if we do this :

print(a,a,a) # the result will be

(1,2,3) (1,2,3) (1,2,3)

Explanation:

Answered by poojan
11

Given a=(1, 2, 3)

The difference is that a*3 repeats the elements of the tuple 3 times in the given order as a whole and encloses them into the given iterable, i.e., tuple. While (a, a, a) is nothing but the enclosing of iterables, i.e., tuples a - as it is - into a new tuple.

a*3 = (1, 2, 3, 1, 2, 3, 1, 2, 3)

(a, a, a) = ( (1, 2, 3), (1, 2, 3), (1, 2, 3) )

Learn more:

What is list comprehension python?

brainly.in/question/6964716

brainly.in/question/16086791

Difference between tuple and list.

brainly.in/question/13319756

Similar questions