Posts

Showing posts with the label Tuples - Data Structures

Python3 Tuples DS

Python Data Structures : Tuple  Data Structures : Tuple  Tuples    ->A tuple is similar to list.    ->The difference between the two is that we can't change the elements of the tuple(immutable) once it is assigned whereas in the list, elements can be changed. Tuple Creation : Eg :              #empty tuple        t=( )                #tuple having integers        t=(1,2,3)        print(t)          #tuple with mixed data types        t=(1,'rama',2.5,'a')        print(t)         #nested tuple        t=(1,(1,2),[1,'abc',3])        print(t) output:: (1,2,3)              (1,'rama',2.5,'a')              (1,(1,2),[1,'abc',3])         #only parentheses is not enough            t=('raja')            type(t) output: : str         # need a comma at the end             t=('raju',)             type(t)  output:: tuple        #paranthesis is optional               t="raja",              print(type(t))