-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictonary.py
More file actions
74 lines (41 loc) · 1.07 KB
/
Copy pathDictonary.py
File metadata and controls
74 lines (41 loc) · 1.07 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#Dictionary
#this is un orderd key value pair
#dict use more memory - key & values
dictanory = {
'a':[1,2,3,4],
'b':'hello',
'c':1
}
print(dictanory)
dictanory2 ={
123 :[1,2,3,4],
True:'hello',
'[100]':100
}
#keys in the dict should be a immutable value , that means it cnnot be chged aftre the dicleration
print(dictanory2)
#when we insert same key with two values , then the second value will over ride the first Value
user ={
'name' :'pasindu',
'age' :24,
'marks' :10
}
#this will print the user details
print(user)
#this print the age of the user, if didnt exists then print 30
print(user.get('age',30))
#this print the job of the user, if didnt exists then print student
print(user.get('job','student'))
print(user)
#this is a nother way of creatig the user
user2 =dict(name='pasindu')
print(user2)
print('name' in user)
print('name' in user.keys())
print( user.items())
user3=user.copy()
user.clear()
print(user)
print(user3)
user.update({'age':30})
print(user)