forked from anmolkumari/Python_4_DataScience
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary.py
More file actions
55 lines (40 loc) · 1021 Bytes
/
dictionary.py
File metadata and controls
55 lines (40 loc) · 1021 Bytes
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
47
48
49
50
51
52
53
54
55
#This is about dictionary:
"""it is actually a datatype that is unordered,non indexable,hash like structure with key and value pair where the key is supposed to be a immuatble type while no suc restriction happens for the value
"""
"""why we cannot index dictionary?
->because it is unordered"""
#declaration
dic={1:"A",2:"B",3:"C",4:"D",5:"E"}
print(dic)
#list of dictionaries
#list of dictionary inside dictionary
person=[{
"name":{"Anmol","Kumari","none"},
"age":19,
"height":160
},{
"name":"Anshu",
"age":20,
"height":170
}]
#list of dictionary
person2=[{
"name":"Tridib",
"Age":20,
"height":177
},{
"name":"Ankit",
"age":20,
"height":175
}]
print(person2)
"""Homework: level1 : ------------
level 2:------------
level3:------------
level 4:------"""
x=dic[3] # we pass the key to fetch value
print(x)
print(dic[5])
#using get()->value, we pass the key to fetch value
x=dic.get(5)
p