Can assigment statements within a function body affect the global frame?
Answer
assignment statements within a function body cannot affect the global frame
Tags
#python #sicp
Question
Can assigment statements within a function body affect the global frame?
Answer
?
Tags
#python #sicp
Question
Can assigment statements within a function body affect the global frame?
Answer
assignment statements within a function body cannot affect the global frame
If you want to change selection, open original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open it The effect of an assignment statement is to bind a name to a value in the
first frame of the current environment. As a consequence, assignment
statements within a function body cannot affect the global frame. The fact
that functions can only manipulate their local environment is critical to
creating modular programs, in which pure functions interact only via the
values they
take and return.
Original toplevel document
1.5 Control put: Global percent_difference result 25.0 percent_difference x 40 y 50 difference 10 Returnvalue 25.0 func percent_difference(x, y)
<span>The effect of an assignment statement is to bind a name to a value in the
first frame of the current environment. As a consequence, assignment
statements within a function body cannot affect the global frame. The fact
that functions can only manipulate their local environment is critical to
creating modular programs, in which pure functions interact only via the
values they
take and return.
Of course, the percent_difference function could be written as a single
expression, as shown below, but the return expression is more complex.
>>> def percent_difference(
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.