(Lecture 2) Functions, Memory Model, Function Design
(Lecture 2) Functions, Memory Model, Function Design
• Abstraction
• Assignment
• Memory model
Computing Bootcamp SNU Graduate School of Data Science 1
Computing Bootcamp
Functions
Lecture 2-1
Hyung-Sin Kim
• Function body is indented! Without the indentation, you will see an error
• Indentation must be the same block of codes
• Most functions have a return statement at the end of the function body
• return <<expression>>
• It evaluates the expression, produces a value, which is the result of the function
call
Hyung-Sin Kim
• Step 2: Create a namespace to hold the function call’s local variables, including
the parameters.
• Step 3: Pass the resulting argument values into the function by assigning them to
the parameters
• Step 4: Execute the function body. When a return statement is executed, the
function terminates and the value of the expression in the return statement is used
as the value of the function call
• x=5
• x = doubling(x+5)
Function Design
Lecture 2-3
Hyung-Sin Kim