Q. If a is (1, 2, 3)

(a) what is the difference (if any) between a * 3 and (a, a, a)?

(b) is a * 3 equivalent to a + a + a ?

(c) what is the meaning of a[1:1] ?

(d) what is the difference between a[1:2] and a[1:1] ?


You can understand by Watching video :-




Answer =

A = a*3 will print three times of tuple in a single tuple
>>>(1,2,3,1,2,3,1,2,3)
(a,a,a) will print nested tuple.
>>>((1,2,3),(1,2,3),(1,2,3))

B = yes

C = it mean that it will not give any e value because it is start from index number 1 but stop at index number 1 but as we know that in slicing it is start from 1 and stop up at 1  so it will print empty tuple.

D = a[1:2] will print value at index number 1 while,
a[1:1] will print empty tuple.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post