CSC108H5 Lecture Notes - Lecture 3: Memory Address

12
CSC108H5 Full Course Notes
Verified Note
12 documents
Document Summary
Which of the following contains a function call? (1) type (4. 5) (2) def add_one(x): return x+1 (3) area(2,9) (4) print( hello ) * arguments can have more have one, comma separated. How it"s executed: each argument is an expression. Evaluate these expressions, in order: store references to those evaluated expressions in the corresponding parameters, execute the body of the function. What are the bugs in the following code? def add_one(x): return x+1 x = 2 x = x+add_one(x: no bugs. The code is fine: the function body is not indented, x is used as a parameter and a variable, and it can"t be both, both b and c are bugs. *it is possible to use x in both the parameter and variable. This is because the parameter x is a local x while as the variable x is a different. You can separate the two if they are in two different locations.