-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictonary2.py
More file actions
44 lines (43 loc) · 816 Bytes
/
dictonary2.py
File metadata and controls
44 lines (43 loc) · 816 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
x={}
x["name"]="ramanuj"
x["age"]=20
x["rollno"]=50
x["marks"]=90
x["address"]="dwarka"
print(x)
print(x["name"])
print(x.get("number",86))
print(x)
x["x1"]=[1,2,4,8]
print(x)
y=x.copy()
z=dict.fromkeys(y)
print(z)
print(x)
print(x.items()) # everything in paranthesis tuple is collection collections
for items in x.items():
print(items)
for keys in x.keys():
print(keys)
for values in x.values():
print(values)
x.setdefault("house","janta flat")# it does not overwrite it give new value if keys is same it doesnot give values
print(x)
#x2=("class":"python")
x.update({"class":"python"})
print(x)
x3=([("name","anuj"),("age","na")])
print(x)
"""def dict(a,b):
a=4+5
b=6+7
return a,b
c={a:b}
d=dict(c)"""
x.pop("house")
print(x)
x.clear()
print(x)
l=[0,1,1,0,0,1]
print(any(l))
print(all(l))