We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2dac319 + 33f6936 commit 19458c5Copy full SHA for 19458c5
unit8_ex8.3.1.py
@@ -0,0 +1,42 @@
1
+# exercise 8.3.1 from unit 8
2
+'''
3
+given the dict:
4
+my_dict = {(1, 2): 1, (2, 3): 2}
5
+
6
+Here are four pieces of code. Choose the output obtained by running each of the code segments.
7
8
9
+# 1:
10
11
12
13
+for key in my_dict.keys():
14
+ print(key)
15
16
+# Answer: (1,2) and (2,3)
17
18
+# 2:
19
20
+for value in my_dict.values():
21
+ print(value)
22
23
+# Answer: 1 and 2
24
25
+# 3:
26
27
+print(len(my_dict))
28
29
+# Answer: 2
30
31
+# 4:
32
33
+print(my_dict[1])
34
35
+# Answer: KeyError
36
37
+# 5:
38
39
+print(my_dict[1, 2])
40
41
+# Answer: 1
42
0 commit comments