forked from chavarera/PythonScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.BasicOfDictionary.py
More file actions
46 lines (33 loc) · 1.28 KB
/
1.BasicOfDictionary.py
File metadata and controls
46 lines (33 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
##------------------------------------------------------------------------------------------------------
#Created By:Ravishankar Chavare
#version:python 3.7
#Date:15/03/2019
#File_des:Introduction of Dictionary Data Structure
##------------------------------------------------------------------------------------------------------
'''
Dictionary:
-Dictionary holds key:value pair which unlike other data types that hold only single element
-Key value is provided in the dictionary to make it more optimized.
-Python Dictionary works similar to real world Dictionary when key element is uniques
'''
#create Simple Dictionary
blankdict=dict()
#Dict with element
elemntdict={'name':'jhon','roll':20,'college':'MIT'}
#simple print dict
print(elementdict)
#-----------------------------------------------------------------------------------------
# Accessing Values and keys From dictionary
#-----------------------------------------------------------------------------------------
#print name from dictionary
name=elemntdict['name']
print(name)
#Accessing Only keys from dictionary
keys=elemntdict.keys()
print(key)
#Accessing Values Only
vals=elemntdict.values()
print(vals)
#useing For Loop iterate the dictionary
for key,value in elemntdict.items():
print(key,value)