本 Wiki 开启了 HTTPS。但由于同 IP 的 Blog 也开启了 HTTPS,因此本站必须要支持 SNI 的浏览器才能浏览。为了兼容一部分浏览器,本站保留了 HTTP 作为兼容。如果您的浏览器支持 SNI,请尽量通过 HTTPS 访问本站,谢谢!
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
cs:fundamental:cs61a:week_1 [2023/09/26 04:36] – [Local Assignment] codinghare | cs:fundamental:cs61a:week_1 [2023/10/27 05:54] (当前版本) – [Conditional statement] codinghare | ||
---|---|---|---|
行 294: | 行 294: | ||
< | < | ||
</ | </ | ||
+ | * 首先会评估 header | ||
+ | * 某个 header 为 true, 则执行该 Header 下的 suite,其他的 suite 将会被跳过。 | ||
===Iteration=== | ===Iteration=== | ||
<code py> | <code py> | ||
行 300: | 行 302: | ||
</ | </ | ||
===Testing=== | ===Testing=== | ||
+ | ==Assertions== | ||
+ | python 中可以使用 '' | ||
+ | <code py> | ||
+ | >>> | ||
+ | assert fib(2) == 1, 'The 2nd Fibonacci number should be 1' | ||
+ | assert fib(3) == 1, 'The 3rd Fibonacci number should be 1' | ||
+ | assert fib(50) == 7778742049, 'Error at the 50th Fibonacci number' | ||
+ | </ | ||
+ | ==Doctest== | ||
+ | // | ||
+ | <code py> | ||
+ | >>> | ||
+ | """ | ||
+ | >>> | ||
+ | 55 | ||
+ | >>> | ||
+ | 5050 | ||
+ | """ | ||
+ | total, k = 0, 1 | ||
+ | while k <= n: | ||
+ | total, k = total + k, k + 1 | ||
+ | return total | ||
+ | | ||
+ | >>> | ||
+ | >>> | ||
+ | TestResults(failed=0, | ||
+ | </ |