#python #sicp
When the expression being asserted evaluates to a true value, executing an
assert statement has no effect. When it is a false value, assert causes an
error that halts execution.
If you want to change selection, open document below and click on "Move attachment"
1.5 Control 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'
<span>When the expression being asserted evaluates to a true value, executing an
assert statement has no effect. When it is a false value, assert causes an
error that halts execution.
A test function for fib should test several arguments, including extreme
values of n .
>>> def fib_test():
assert fib(2) == 1, 'The 2nd Fibonacci number should b Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details