(Solved):What is the output of print(tuple[2:]) if tuple = (‘abcd’, 786, 2.23, ‘john’, 70.2)? View Answer…

 

Question

What is the output of print(tupleNo InterWiki reference defined in properties for Wiki called “2”!) if tuple = (‘abcd’, 786, 2.23, ‘john’, 70.2)?

 

EXPERT ANSWER

The output of the given statement would be (2.23, ‘john’, 70.2).

This is a feature of Python programming language which is called slicing. It returns a sub-set of elements from a list, a tuple, an array or any custom data structure. In the given statement, the tuple

Scroll to top