#python #sicp
Assertions. Programmers use assert statements to verify expectations,
such as the output of a function being tested. An assert statement has an
expression in a boolean context, followed by a quoted line of text (single or
double quotes are both fine, but be consistent) that will be displayed if the
expression evaluates to a false value.
If you want to change selection, open document below and click on "Move attachment"
1.5 Controlmost functions, which are meant to be general, tests
involve selecting and validating calls with specific argument values. Tests
also serve as documentation: they demonstrate how to call a function and what
argument values are appropriate.
<span>Assertions. Programmers use assert statements to verify expectations,
such as the output of a function being tested. An assert statement has an
expression in a boolean context, followed by a quoted line of text (single or
double quotes are both fine, but be consistent) that will be displayed if the
expression evaluates to a false value.
>>> assert fib(8) == 13, 'The 8th Fibonacci number should be 13'
When the expression being asserted evaluates to a true value, executing an
assert statement has no effect Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details