-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdict.py
More file actions
51 lines (44 loc) · 768 Bytes
/
Copy pathdict.py
File metadata and controls
51 lines (44 loc) · 768 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
# dictionary
a={
"name":str(input('enter name')),
"age": int(input('enter age')),
"age": 21,
"class":str(input('enter class'))
}
# any duplicate key word will over write the old.
print(a)
print(type(a))
print(a["name"])
print(len(a))
b=a["class"]
print(b)
y=a.get("name")
print(y)
print('\n\n')
#for all key words in dict
z=a.keys()
print(z)
print('\n\n')
# for all values.
w=a.values()
print(w)
print('\n\n')
#adding a key an value
a["attan"]=int(input('enter your attendance'))
print(z)
print(a)
print('\n\n')
# for all items of dict
b=a.items()
print(b)
print('\n\n')
"""
# for removing an item
a.pop("age")
print(a)
"""
# from keys makes all same values different keys
h=("name","age","rollno.")
j=("vikrant",20,328612978)
l=dict.fromkeys(h,j)
print(l)