Check Your Understanding Draw the environment diagram def square(x): return xX def sum_of_squares(x,y): return square(x)+square(y) sum_of_squares(3,4)
Draw the environment diagram def square(x): return x * x def sum_of_squares(x, y): return square(x) + square(y) sum_of_squares(3, 4) Check Your Understanding
Review:Evaluation Order Demo Remember to evaluate the operator,then the operand(s),then apply the operator onto the operand(s). def add_one(x): Evaluate the operator.A Evaluate the operand.. y=X+1 function value is returned return y Returns 10 Returns 100 def square(x): Evaluate the operator.A Evaluate the operand.Now we have evaluate another return xx function value is returned expression. What will the environment diagram look like?(When are frames created?) The environment diagram should reflect Python's evaluation
square(add_one(9)) Review: Evaluation Order def add_one(x): y = x + 1 return y def square(x): return x * x Remember to evaluate the operator, then the operand(s), then apply the operator onto the operand(s). What will the environment diagram look like? (When are frames created?) The environment diagram should reflect Python’s evaluation. Evaluate the operator. A function value is returned Evaluate the operand. Now we have evaluate another expression. Evaluate the operator. A function value is returned Evaluate the operand.. Returns 10 Returns 100 Demo