-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.py
More file actions
46 lines (35 loc) · 987 Bytes
/
Copy path8.py
File metadata and controls
46 lines (35 loc) · 987 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
#dictionery kkey = value
meaning = {
"bat":"used to hit",
"ball":"used to paly"
}
print(type(meaning))
print(meaning["bat"]) #accesing dict
print(meaning.get("wicket" , "not found")) #safe access method for remove error .use .get
meaning["wicket"]="ued to diclare out" #add dict to variable in run time
print(meaning)
meaning["bat"]="used to fight" # updating variable in run time
print(meaning)
meaning.pop("bat") #remove key
print(meaning)
# del meaning["ball"] another way to remove or delete
print(meaning)
print(meaning.keys()) # only keys are print
print(meaning.values())# only values are print
print(meaning.items()) # it will give keys and values in list
games={
"cricket":"famous",
"volly ball":"play",
"kabbadi":"physical"
}
meaning.update(games) #updating one dict to another
print(meaning)
items1={
"balll":3,
"price":30
}
items2={
"bat":1,
"price":500
}
print(f"total price:{items1["price"] + items2["price"]}")