Creating a dictionary and traversing

d={10: 'iprg' , 22: 'Nan', 33:'Kool',8: 'Jool' } # Creating a dictionary with key: value pair

for i in d:                                     # Here key and the vaule can be any type.
  print i,d[i]                                  # Accessing elements in the dictionary

# Order in which they display is also different in output

print d.keys()  # print all keys in a dictionary

print d.values()  # print all values in a dictionary


Tuples Manipulation

try:
      l=['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
      print 'List :',l
      tup1 = tuple(l) #Converts a list into tuple
      tup2=(1,2,3,4,5,6,7)
      #Adding two Tuples
      tup=tup1+tup2
      print 'New added tuple :',tup
      ntup=tup2*2
      print 'New multiplyed tuple:',ntup
      p=max(tup1)
      print 'The tuple with max value:',p
      p1=min(tup1)
      print 'The tuple with min value:',p1
      #Compares elements of both tuples and same return 0 otherwise -1
      k=cmp(tup2,ntup)
      print k
      #Delete Tuple
      del tup
      print tup
except:
      print 'Tuple does not exist'