#python #sicp
So far, local assignment hasn't increased the expressive power of our function
definitions. It will do so, when combined with other control statements. In
addition, local assignment also plays a critical role in clarifying the meaning
of complex expressions by assigning names to intermediate quantities.
If you want to change selection, open document below and click on "Move attachment"
1.5 Controlence function could be written as a single
expression, as shown below, but the return expression is more complex.
>>> def percent_difference(x, y):
return 100 * abs(x-y) / x
>>> percent_difference(40, 50)
25.0
<span>So far, local assignment hasn't increased the expressive power of our function
definitions. It will do so, when combined with other control statements. In
addition, local assignment also plays a critical role in clarifying the meaning
of complex expressions by assigning names to intermediate quantities.
1.5.4 Conditional Statements
Video:
Show
Hide Python has a built-in function for computing absolute values.
>>> abs(-2)
2
We would like to be able to implement Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details