# dictionary
school={'techers':7,'students':20,'janitor':1,'cook':3,'principal':1,'cashier':2}
print school
#updating a dictionary
school["sponsor"]=6
print school
#printing key and values in a dict
print school.keys()
#print value of a key
print school['students']
#deleting an item from diet
del(school['janitor'])
print school
print len(school)
#empty diet
menu={}
menu['wine']=21.50
menu['rice']=12.5
menu['fufu']=13
menu['peza']=24.6
menu['cake']=3.00
menu['frie chicken']=5.00
menu['softdrink']=35.00
menu['cornbread']=45.00
menu['dosa']=16.00
print menu
for item in menu:
print menu[item]
for key,value in menu.items():
print key,value
citizens={'liberia':'liberians','Nigeria':'nigerians','Americans':['chinese','europeans','africans','asians']}
print citizens
#using for loops
for key,value in citizens.items():
print key,value
citizens['Americans'].sort()
print citizens
citizens['brazil']=['brazilians','south american']
print citizens
No comments:
Post a Comment