8000 Python Data-type Dictionary · aworleo/programminginpython.com@bfbe0dc · GitHub
[go: up one dir, main page]

Skip to content

Commit bfbe0dc

Browse files
committed
Python Data-type Dictionary
1 parent 5f551e1 commit bfbe0dc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

dictionaryOperations.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
__author__ = 'Avinash'
2+
3+
# add elements to dictionary
4+
my_info = {
5+
'Name': 'Avinash',
6+
'Age': 23,
7+
'Gender': 'Male',
8+
'Location': 'India',
9+
'Website': 'programminginpython.com'
10+
}
11+
12+
# print dictionary
13+
print(my_info)
14+
15+
# print value of a key
16+
print(my_info['Name'])
17+
18+
# modify elements in dictionary
19+
my_info['Age'] = 24
20+
print(my_info)
21+
22+
# length of dictionary
23+
print(len(my_info))
24+
25+
# delete a particular key
26+
del my_info['Website']
27+
print(my_info)
28+
29+
# removes all elements in dictionary
30+
my_info.clear()
31+
print(my_info)
32+
33+
# delete entire dictionary
34+
del my_info

0 commit comments

Comments
 (0)
0