1
00:00:08,120 --> 00:00:10,425
So, in this question,

2
00:00:10,425 --> 00:00:12,824
we ask what's printed by the following statements.

3
00:00:12,824 --> 00:00:16,770
So, mydict is a dictionary with four key value pairs,

4
00:00:16,770 --> 00:00:20,085
and we print out mydict.get cat,

5
00:00:20,085 --> 00:00:23,100
divided by mydict.get dog.

6
00:00:23,100 --> 00:00:27,675
Here, we're using division without a remainder which just gives us an integer.

7
00:00:27,675 --> 00:00:30,480
Mydict.get cat is 12,

8
00:00:30,480 --> 00:00:33,375
and mydict.get dog is six,

9
00:00:33,375 --> 00:00:37,805
and so the value of 12 over six is going to be two.

10
00:00:37,805 --> 00:00:41,180
So, in this question,

11
00:00:41,180 --> 00:00:43,565
we're asked what's printed by the following statement?

12
00:00:43,565 --> 00:00:46,190
So, we create that same dictionary, and now,

13
00:00:46,190 --> 00:00:49,010
we print out the value dog in mydict,

14
00:00:49,010 --> 00:00:52,670
so that asks, is dog a key in my dictionary?

15
00:00:52,670 --> 00:00:54,160
We can see that it is.

16
00:00:54,160 --> 00:00:55,495
It has the value six,

17
00:00:55,495 --> 00:00:59,285
but all we care about is that it is a key.

18
00:00:59,285 --> 00:01:05,695
Here, we create that same dictionary and we print out the value 23 in mydict.

19
00:01:05,695 --> 00:01:10,175
Here, we have a key elephant that has the value 23,

20
00:01:10,175 --> 00:01:13,910
but remember that in only asks,

21
00:01:13,910 --> 00:01:17,920
is 23 a key in my dictionary?

22
00:01:17,920 --> 00:01:19,410
In this case, it's not.

23
00:01:19,410 --> 00:01:20,700
Our only keys are cat,

24
00:01:20,700 --> 00:01:22,480
dog, elephant, and bear.

25
00:01:22,480 --> 00:01:25,620
It doesn't matter that it just so happens to be a value.

26
00:01:25,620 --> 00:01:31,830
The value here of this overall expression is going to be false.

27
00:01:31,940 --> 00:01:35,310
So, here, we first assign total to be

28
00:01:35,310 --> 00:01:38,960
zero and then we create the same dictionary that we had before,

29
00:01:38,960 --> 00:01:42,475
and we loop through all of the keys in our dictionary.

30
00:01:42,475 --> 00:01:44,550
So, A key is going to be cat,

31
00:01:44,550 --> 00:01:46,590
dog, elephant, and bear,

32
00:01:46,590 --> 00:01:49,320
not necessarily in that order, and we say,

33
00:01:49,320 --> 00:01:51,090
if the length of that key,

34
00:01:51,090 --> 00:01:53,795
so every one of these keys is a string.

35
00:01:53,795 --> 00:01:57,085
So, if that string is longer than three characters,

36
00:01:57,085 --> 00:02:00,930
then add its value to total.

37
00:02:00,930 --> 00:02:03,980
So, the first thing I would ask are what are

38
00:02:03,980 --> 00:02:06,905
the keys that are longer than three characters?

39
00:02:06,905 --> 00:02:10,490
That's just going to be elephant and bear.

40
00:02:10,490 --> 00:02:14,315
So, for cat and dog,

41
00:02:14,315 --> 00:02:18,200
this statement is not going to run because

42
00:02:18,200 --> 00:02:23,395
the key cat is not longer than three characters and same thing for the key dog.

43
00:02:23,395 --> 00:02:25,690
So, for elephant and bear,

44
00:02:25,690 --> 00:02:30,500
then we're going to say total equals total plus my dictionary plus that value.

45
00:02:30,500 --> 00:02:36,160
So, we're going to first assign total to be zero plus,

46
00:02:36,160 --> 00:02:38,770
let's suppose that elephant comes before bear,

47
00:02:38,770 --> 00:02:42,415
so zero plus mydict sub elephant,

48
00:02:42,415 --> 00:02:44,570
so zero plus 23,

49
00:02:44,570 --> 00:02:47,070
so total gets the value 23.

50
00:02:47,070 --> 00:02:49,655
Then, by the time we get to the key bear,

51
00:02:49,655 --> 00:02:53,300
then we're going to say total equals its old value,

52
00:02:53,300 --> 00:02:58,540
so 23 plus the value associated with the key bear which is 20,

53
00:02:58,540 --> 00:03:01,030
so 23 plus 20,

54
00:03:01,030 --> 00:03:05,405
which is going to leave total at 43.

55
00:03:05,405 --> 00:03:09,360
So, the answer here is going to be B.

56
00:03:11,230 --> 00:03:15,130
That's all for now. Until next time.