Saturday, 16 March 2019

tuples class 11 python cbse

TUPLES


  • Tuples is also kind as container which can store list of any kind of values.
  • Tuples is a immutable data type which means we can not change any value of tuple.
  • Tuple is sequence like string and list but the different is that list is mutable whereas string and tuple are immutable.

CREATION OF TUPLES

  • Empty tuple: >>>t = ( ) 
  • Single tuple: >>>t = (1)
  • Nested tuple: >>>t = (1,12,2,(2,3))
  • Long tuple: >>>t = (1,2,3,4,5,6,7)

Tuple functions 

  • len( ) function
  • max( ) function
  • min ( ) function
  • index ( ) function
  • tuple( ) function

Unpacking Tuple

Forming a tuple from individual value is called packing and creating individual values from a tuple element is unpacking.

FOR EXAMPLE:

t = (1,2,'A','B')
length= 4
w,x,y,z= t
print(w)

         1


No comments:

Post a Comment