#python #sicp
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.
If you want to change selection, open document below and click on "Move attachment"
1.5 Controlput: 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 read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details