What happens when an assert statement evalutes to true? False?
Answer
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.
Tags
#python #sicp
Question
What happens when an assert statement evalutes to true? False?
Answer
?
Tags
#python #sicp
Question
What happens when an assert statement evalutes to true? False?
Answer
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 original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open it 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.
Original toplevel document
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 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.