Upload
tc-ahmet-ayhan-altunoglu
View
216
Download
0
Embed Size (px)
Citation preview
8/13/2019 Dictionaries 130820012026 Phpapp02
1/13
8/13/2019 Dictionaries 130820012026 Phpapp02
2/13
Disclaimer: This presentation is prepared bytrainees of baabtra as a part of mentoringprogram. This is not official document ofbaabtra Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System
Technologies Pvt . Ltd
8/13/2019 Dictionaries 130820012026 Phpapp02
3/13
Week Target Achieved
1 40 23
2 40 26
3
Typing peed
8/13/2019 Dictionaries 130820012026 Phpapp02
4/13
Jobs !!lied! "ompany Designation Applied
Date"urrent
tatus
1
2
3
8/13/2019 Dictionaries 130820012026 Phpapp02
5/13
Dictionaries in Python shafee"#e
shafee"#emon!$gmail.com
%%%.faceboo&.com'shafee"#emon!!ambodan
t%itter.com'shafee"#emon!
in.lin&edin.com'in'shafee"#emon!
()*(+1132,
8/13/2019 Dictionaries 130820012026 Phpapp02
6/13
Python ictionary
A dictionary is mutable and is another container type that canstore any number of Python objects
Dictionaries consist of pairs (called items) of keys and theircorrespondin !alues"
Python dictionaries are also kno#n as associati!e arrays orhash tables "
$he eneral synta% of a dictionary is as follo#s& dict ' A & 234* + , & -*02 + . & 32/1
8/13/2019 Dictionaries 130820012026 Phpapp02
7/13
Python ictionary /eat#res
ach key is separated from its !alue by a colon (&)"
$he items are separated by commas+ and the #hole thin isenclosed in curly braces" An empty dictionary #ithout any items is #ritten #ith just t#o
curly braces+ like this& 1" eys are uni ue #ithin a dictionary #hile !alues may not be $he !alues of a dictionary can be of any type+ but the keys
must be of an immutable data type such as strin s+ numbers+or tuples"
8/13/2019 Dictionaries 130820012026 Phpapp02
8/13
ccessing 0al#es in ictionary
$o access dictionary elements+ you can use the familiar
s uare brackets alon #ith the key to obtain its !alue" 5or e%ample& dict ' ame & 7ara + A e & 8+ .lass & 5irst19
print :dict; ame
8/13/2019 Dictionaries 130820012026 Phpapp02
9/13
!dating ictionary
o# can #!date a dictionary by adding a ne% entry or item i.e.4 a&ey-val#e !air56.e
modifying an e7isting entry4 or deleting an e7isting entry as sho%nbelo% in the sim!le e7am!le
dict 8 9 :;ame: :lass: :/irst: ?@
dictA: ge: 8 ) @C #!date e7isting entrydictA:School: 8 D PS SchoolD @C dd ne% entry
!rint DdictA : ge: D4 dictA: ge: @!rint DdictA :School: D4 dictA:School: @
E#t!#tdictA: ge: )
dictA:School: PS School
8/13/2019 Dictionaries 130820012026 Phpapp02
10/13
elete ictionary Flements
o# can either remove individ#al dictionary elements or clear theentire contents of a dictionary
$o e%plicitly remo!e an entire dictionary+ just use the del statement"i"e&
dict ' ame & 7ara + A e & 8+ .lass & 5irst19 del dict; ame remo!e entry #ith key ame
dict"clear() 9 > remo!e all entries in dictdel dict 9 > delete entire dictionary
print :dict; A e
8/13/2019 Dictionaries 130820012026 Phpapp02
11/13
Properties of Dictionary Keys:
$here are t#o important points to remember about dictionary keys &
(a) Bore than one entry per key not allo#ed" Chich means no duplicate key is allo#ed"Chen duplicate keys encountered durin assi nment+ the last assi nment #ins"
i"e&
dict ' ame & 7ara + A e & 8+ ame & Banni19
print :dict; ame
8/13/2019 Dictionaries 130820012026 Phpapp02
12/13
6f this !resentation hel!ed yo#4 !lease visit o#r !agefaceboo&.com' baabtra and li&e it.
Than&s in advance .
%%%.baabtra.com H%%%.massbaab.com H%%%.baabte.com
http://facebook.com/baabtrahttp://facebook.com/baabtrahttp://www.baabtra.com/http://www.massbaab.com/http://www.baabte.com/http://www.baabte.com/http://www.massbaab.com/http://www.baabtra.com/http://facebook.com/baabtrahttp://facebook.com/baabtra8/13/2019 Dictionaries 130820012026 Phpapp02
13/13
ontact #s
Fmarald Mall Big BaIar B#ilding5
Mavoor oad4 KoIhi&ode4Kerala4 6ndia.Ph (1 N(, N* 2, ,,*
;> >om!le74 ;ear B#s Stand
M#&&am4 KoIhi&ode4Kerala4 6ndia.Ph (1 N(, N* 2, ,,*
Start #! 0illageFranalam4
Kerala4 6ndia.Fmailinfo$baabtra.com