tutorials, python tutorial,python 3 tutorial

Python tutorial

Python Dictionary Object

     Dictionary is a mapped data structure, which has key:value pair as an elements, key is immutable object, values can be mutable

Various Ways to create a Dictionary object in Python

dict()create a empty dictionary object
dict(mapping)create a dictionary from mapping
dict(iterable)create a dictionary from iterable
dict(**kwargs)create a dictionary from key word args

create a empty dictionary object

		>>> d={}

create a dictionary from mapping

		>>>def fn(key,value):
		      return key,int(value)

create a dictionary from iterable

		d=dict( [('a',1),('b',2),('c',3),('d',4),('e',5),('f',6)] )	

create a dictionary from key word args

		>>>d = dict(one=2,two=3,three=4,four=5,five=6)

Adding Elements to Dictionary Object

Remove to Dictionary Object

Update Dictionary element

Iterate Dictionary Object

  • d.keys
  • d.values
  • d.items