Transcript

The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make a donation or view additional materials from hundreds of MIT courses, visit MIT OpenCourseWare at ocw.mit.edu. I have two functions here. One is add and one is multiply. The add function returns the sum of x + y and the multiply function just prints the value of x * y. What doesn't return the value. Instead, it's going to implicitly return none. Right? Because we don't have any return statement inside mult. So, there are four lines here.

And the question was how many total lines of output will show up if you run the code. Okay? So, how many lines in the console will show up? Okay. So, when I do first add one two, it's going to go inside this function here and it's say it says x is one, y is two, and return three. So, I'm replacing this line with three, but notice I'm never printing it out. So, this line of code will not print out anything. Instead, if I do uh So, in addition So, the next line is if I print add 2 + 3, then I'm going to get five and I'm going to print that out. So, that's one one thing I'm printing out. Next line says multiply three and four.

So, I'm going to go inside my mult function and say x is three, y is four. So, I'm going to print 12. So, 3 * 4 is 12. So, that's another thing that gets printed out. And I'm not doing anything with the output or the Sorry, I'm not doing anything with the return from mult. So, that line is is is done. And the last one is is the trickiest and it says print mult four and five. So, first I'm going to go in here. X is four, Y is five and I'm printing 20. So, that's another print. And the return of this function is going to be none, right? And the main thing here is I'm going to print the return of this function.

So, I'm also going to print out none. So, that's another one. So, in total I'm going to have four different things printed out. The last one being this none.