1 00:00:00,790 --> 00:00:03,190 The following content is provided under a Creative 2 00:00:03,190 --> 00:00:04,730 Commons license. 3 00:00:04,730 --> 00:00:07,030 Your support will help MIT OpenCourseWare 4 00:00:07,030 --> 00:00:11,390 continue to offer high quality educational resources for free. 5 00:00:11,390 --> 00:00:13,990 To make a donation or view additional materials 6 00:00:13,990 --> 00:00:17,880 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:17,880 --> 00:00:18,850 at ocw.mit.edu. 8 00:00:23,830 --> 00:00:27,880 PROFESSOR: So now we have this last exercise. 9 00:00:27,880 --> 00:00:30,310 I'm creating a mysum. 10 00:00:30,310 --> 00:00:32,327 I'm going to go through all of these values 11 00:00:32,327 --> 00:00:34,660 and you guys have already told me what values these are, 12 00:00:34,660 --> 00:00:39,640 5, 7, 9, not 11. 13 00:00:39,640 --> 00:00:41,440 And I'm going to add to mysum. 14 00:00:41,440 --> 00:00:44,320 So I'm going to keep a running sum adding all of these values 15 00:00:44,320 --> 00:00:47,090 together. 16 00:00:47,090 --> 00:00:51,010 So the very first time through the loop, mysum 17 00:00:51,010 --> 00:00:55,410 gets the value of 5. 18 00:00:55,410 --> 00:00:57,480 That's this line here. 19 00:00:57,480 --> 00:01:01,280 The next thing I see inside this loop is an if statement. 20 00:01:01,280 --> 00:01:03,510 If mysum is equal to 5. 21 00:01:03,510 --> 00:01:06,330 That's true. 22 00:01:06,330 --> 00:01:08,840 So I'm going to go inside this if statement. 23 00:01:08,840 --> 00:01:10,430 The next thing I see is a break. 24 00:01:13,220 --> 00:01:15,300 If I see this break am I evaluating-- 25 00:01:15,300 --> 00:01:18,180 am I evaluating this line or not? 26 00:01:18,180 --> 00:01:19,600 No, exactly. 27 00:01:19,600 --> 00:01:23,990 Because whenever Python sees break, it's going to say, 28 00:01:23,990 --> 00:01:26,510 I'm going to stop right here, exit out of the loop 29 00:01:26,510 --> 00:01:29,960 that I'm currently in, and go to the statement that's 30 00:01:29,960 --> 00:01:32,220 immediately right after it. 31 00:01:32,220 --> 00:01:34,820 So what this is going to print is mysum. 32 00:01:34,820 --> 00:01:37,280 And that's the exercise we were looking at. 33 00:01:37,280 --> 00:01:39,000 Let's see how the class did. 34 00:01:41,491 --> 00:01:41,990 Pretty good. 35 00:01:45,370 --> 00:01:48,450 Hopefully if you answered one of these, 36 00:01:48,450 --> 00:01:50,370 the explanation was-- was all right. 37 00:01:50,370 --> 00:01:54,410 If not, just go back and try to work through it step by step.