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,860 at ocw.mit.edu. 8 00:00:24,930 --> 00:00:26,850 ANA BELL: I have two functions here. 9 00:00:26,850 --> 00:00:30,150 One is add, and one is multiply. 10 00:00:30,150 --> 00:00:34,680 The add function returns the sum of x plus y. 11 00:00:34,680 --> 00:00:39,940 And the multiply function just prints the value of x times y, 12 00:00:39,940 --> 00:00:42,310 but doesn't return the value. 13 00:00:42,310 --> 00:00:45,520 Instead, it's going to implicitly return none 14 00:00:45,520 --> 00:00:50,680 because we don't have any return statement inside mult. 15 00:00:50,680 --> 00:00:53,020 So there are four lines here. 16 00:00:53,020 --> 00:00:55,240 And the question was how many total lines of output 17 00:00:55,240 --> 00:00:57,710 will show up if you run the code? 18 00:00:57,710 --> 00:01:02,560 OK, so how many lines in the console show up? 19 00:01:02,560 --> 00:01:04,900 So when I do first add 1, 2, it's 20 00:01:04,900 --> 00:01:08,900 going to go inside this function here and say-- it says x is 1, 21 00:01:08,900 --> 00:01:11,950 y is 2, and return 3. 22 00:01:11,950 --> 00:01:13,840 So I'm replacing this line with 3. 23 00:01:13,840 --> 00:01:15,790 But notice I'm never printing it out. 24 00:01:15,790 --> 00:01:19,980 So this line of code will not print out anything. 25 00:01:19,980 --> 00:01:25,650 Instead, the next line is if I print add 2 plus 3, 26 00:01:25,650 --> 00:01:26,820 then I'm going to get 5. 27 00:01:26,820 --> 00:01:28,210 And I'm going to print that out. 28 00:01:28,210 --> 00:01:31,840 So that's one thing I'm printing out. 29 00:01:31,840 --> 00:01:35,950 The next line says multiply 3 and 4. 30 00:01:35,950 --> 00:01:38,970 So I'm going to go inside my mult function and say, x is 3, 31 00:01:38,970 --> 00:01:40,890 y is 4. 32 00:01:40,890 --> 00:01:45,414 So I'm going to print 12 because 3 times 4 is 12. 33 00:01:45,414 --> 00:01:47,330 So that's another thing that gets printed out. 34 00:01:51,780 --> 00:01:55,610 And I'm not doing anything with the output-- or sorry, I'm 35 00:01:55,610 --> 00:01:57,860 not doing anything with the return from mult. 36 00:01:57,860 --> 00:02:00,870 So that line is done. 37 00:02:00,870 --> 00:02:03,160 And the last one is the trickiest 38 00:02:03,160 --> 00:02:06,416 and it says print mult 4 and 5. 39 00:02:06,416 --> 00:02:07,790 So first I'm going to go in here. 40 00:02:07,790 --> 00:02:09,229 X is 4, y is 5. 41 00:02:09,229 --> 00:02:10,810 And I'm printing 20. 42 00:02:10,810 --> 00:02:14,290 So that's another print. 43 00:02:14,290 --> 00:02:18,720 And the return of this function is going to be none, right? 44 00:02:18,720 --> 00:02:20,925 And the main thing here is I'm going to print 45 00:02:20,925 --> 00:02:22,320 at the return of this function. 46 00:02:22,320 --> 00:02:24,630 So I'm also going to print out none. 47 00:02:24,630 --> 00:02:27,250 So that's another one. 48 00:02:27,250 --> 00:02:29,970 So in total, I'm going to have four different things printed 49 00:02:29,970 --> 00:02:33,110 out, the last one being this none.