Tutorial #21 || Python Dictionaries || Python Data Structures || Python Tutorials for Beginners

Publié le: 01 janvier 1970
sur la chaîne: Haripriya Manne
64
5

Tutorial #20 || Tuples in Python || Python Data Structures || Python Tutorials for Beginners video Link:    • Tutorial #20 || Tuples in Python || Python...  

Tasks:
1) Take three dictionaries and concatenate all three into one new dictionary
2) A dictionary contains students data( keys → S.No, values → list of name , age ).  Now add a new student data and delete one old student data. Print result in the  format of “S.No : [ name , age ] “  
3) Update your contacts in contact application. 

Sample Dictionary: dict1 = { ' k1 ' : 200, ' k2 ' : 300, ' k3 ' : 400 }
Dictionary Methods :
Description  copy( )  Returns the copy of dictionary 
Example: dict2 = dict1.copy( )  Result: dict2 = { ' k1 ' : 200, ' k2 ' : 300, ' k3 ' : 400 } 

fromkeys( )  Returns specified keys and values 
Example: x = (‘key1’ , ‘key2’) y = 0  newDict = dict.fromkeys(x, y)  Result: newDict = [ ‘key1’ : 0, ‘key2’ = 0 ] 

get( )  Gets the value using particular key. 
Example: dict1.get( ‘ k1 ’ )  Result: 200 

items( )  Returns the list containing tuple for each pair of key and value 
Example: dict1.items( )  Result: ​dict_items ([('k1', 200), ('k2', 300), ('k3', 400)]) 

keys( )  Similar to get( ) method. 
Example: dict1.keys( )  Result: ​dict_keys(['k1', 'k2', 'k3'])   

values( )  Returns the list containing tuple for each pair of key and value 
Example: dict1.items( )  Result: ​dict_items ([('k1', 200), ('k2', 300), ('k3', 400)]) 

pop( )  Removes the value using specified key 
Example: dict1.pop( ‘ k1 ‘ ) 

popitem( )  Removes the key and value at the end of the dictionary 
Example: dict1.popitem( )  Result: dict1 = { ' k1 ' : 200, ' k2 ' : 300 } 

setdefault( )  If key does not exist, this method insert key. Returns the value of particular key 

update( )  Updates the values of specified key 
Example: dict1.update({'color' : 'green'})  Result: dict1 = ​{'k1': 200, 'k2': 300, 'k3': 400, 'color': 'green'} 

clear( )  Removes all items in the dictionary 
Example: dict1.clear( ) Result: { } 

Follow Python Tutorials:    • Python Tutorials for Beginners  

If you want to develop games than don't be late visit this playlist almost 40 Tutorials made just learn by using below lin
Follow Unity 2D Game Development Creepy Cat Tutorials:
   • Unity 2D Game Development Creepy Cat Tutor...  

Follow me on:
► Subscribe to my Channel:    / haripriyamanne  
►Instagram:   / haripriya_manne  
►Website: http://haripriyamanne.byethost10.com/...

If you have any queries can mail me to
haripriyamannetech@gmail.com

Music:
https://www.jiosaavn.com/song/family-...
https://wynk.in/music/song/family-day...

Disclaimer- All videos and content used for educational purpose


Sur cette page du site, vous pouvez voir la vidéo en ligne Tutorial #21 || Python Dictionaries || Python Data Structures || Python Tutorials for Beginners durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Haripriya Manne 01 janvier 1970, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 64 fois et il a aimé 5 téléspectateurs. Bon visionnage!