Professional Documents
Culture Documents
V Balasubramanian
1 Introduction
2 Tuples
3 Immutability
4 Tuple Assignment
8 Summary
9 Reference
All the expressions on the right side are evaluated before any of
the assignments.
This feature makes tuple assignment quite versatile.
>>> x=15
>>> x , y=5, x+2
>>> print ( x , y )
5 17
a L i s t = [ 1 2 3 , ’ xyz ’ , ’ z a r a ’ , ’ abc ’ ]
print ( a L i s t ) −−− [ 1 2 3 , ’ xyz ’ , ’ z a r a ’ , ’ abc ’ ]
aTuple = tuple ( a L i s t )
print ( aTuple ) −−− ( 1 2 3 , ’ xyz ’ , ’ z a r a ’ , ’ abc ’ )
X= ( ( 1 1 , 2 9 , 3 0 ) , ( 1 4 , 2 5 , 1 6 ) )
Y= ( ( 1 2 , 2 0 , 2 ) , ( 1 , 1 0 , 5 ) )
r e s u l t =()
# i t e r a t e t h r o u g h rows
fo r i in range ( len (X ) ) :
# i t e r a t e t h r o u g h columns
row =()
for j in range ( len (X [ 0 ] ) ) :
row = row+(X[ i ] [ j ] + Y[ i ] [ j ] , )
r e s u l t=r e s u l t +(row , )
print ( r e s u l t )
for r in r e s u l t :
print ( r )