-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdict.py
More file actions
63 lines (33 loc) · 973 Bytes
/
Copy pathdict.py
File metadata and controls
63 lines (33 loc) · 973 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
56
57
58
59
60
61
62
d1 = {}
d2 = {"name": "Swapnali", "age": 21, "city": "Pune"}
d3 = dict(id=101, course="Python", duration="3 months")
print(d2)
student = {"name": "Swapnali", "marks": 95, "city": "Pune"}
print(student["name"])
print(student.get("marks"))
print(student.get("gender", "Not Found"))
student = {"name": "Swapnali", "marks": 95}
student["city"] = "Pune"
student["marks"] = 98
print(student)
student = {"name": "Swapnali", "age": 21, "city": "Pune"}
student.pop("age")
print(student)
student.popitem()
print(student)
del student["city"]
print(student)
student.clear()
print(student)
person = {"name": "Swapnali", "age": 21}
print(person.keys())
print(person.values())
print(person.items())
extra = {"city": "Pune"}
person.update(extra)
print(person)
students = {
"101": {"name": "Swapnali", "marks": 95},
"102": {"name": "Riya", "marks": 89}
}
print(students["101"]["name"])