Q. What will be the output of the following code snippet?

 

Tup1 = ((1, 2),) * 7

print (len(Tup1 [3: 8 ]))

 

Answer =

Output is: -

 

4

>>> 


Because


Tup1 = ((1, 2),) * 7


After this Tup1 become

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


Now Len(Tup1[3:8]) strat from index number 3 , 4, 5, 6.


So, output is 4.



3 Comments

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

  1. Replies
    1. Tup1 = ((1, 2),) * 7

      After this Tup1 become
      ((1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2), (1, 2))

      Now Len(Tup1[3:8]) strat from index number 3 , 4, 5, 6.

      So, output is 4.

      Delete

Post a Comment

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

Previous Post Next Post