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
На этой странице сайта вы можете посмотреть видео онлайн Tutorial #21 || Python Dictionaries || Python Data Structures || Python Tutorials for Beginners длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Haripriya Manne 01 Январь 1970, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 64 раз и оно понравилось 5 зрителям. Приятного просмотра!