-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary.py
More file actions
54 lines (40 loc) · 1.01 KB
/
Dictionary.py
File metadata and controls
54 lines (40 loc) · 1.01 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
marks = {
"ayush" : 100,
"Aman" : 39,
"vishal" : 89,
}
print(marks, type(marks))
print(marks,["ayush"])
# It is mutable
# It is indexed
# It is unordered
# cannot contain duplicate keys
# Method of Dictionary............
marks = {
"ayush": 100,
"imtiyaz": 56,
"shreya": 23,
0: "ayush"
}
# print(marks.items())
# print(marks.keys())
# print(marks.values())
# marks.update({"ayush": 99, "varshita": 100})
# print(marks)
print(marks.get("ayush")) # Prints None
print(marks["ayush"]) # Returns an error
# Create an empty dictionary Allow 4 Friend toenter their favourite Code
d = {}
name = input("Enter friends name: ")
lang = input("Enter Language name: ")
d.update({name: lang})
name = input("Enter friends name: ")
lang = input("Enter Language name: ")
d.update({name: lang})
name = input("Enter friends name: ")
lang = input("Enter Language name: ")
d.update({name: lang})
name = input("Enter friends name: ")
lang = input("Enter Language name: ")
d.update({name: lang})
print(d)