What & How & Why

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
后一修订版两侧同时换到之后的修订记录
cs:fundamental:cs61a:week_1 [2023/09/26 04:20] – [Control] codingharecs:fundamental:cs61a:week_1 [2023/09/26 04:36] – [Local Assignment] codinghare
行 261: 行 261:
 </code> </code>
 ==Compound Statements== ==Compound Statements==
 +结构如下:
 +<code py>
 +<header>:
 +    <statement>
 +    <statement>
 +    ...
 +<separating header>:
 +    <statement>
 +    <statement>
 +    ...
 +...
 +</code>
 +<WRAP center round box 100%>
 +根据上述定义,''def'' 属于 //compound statement//
 +</WRAP>
 +上述的结构可以被视作 //sequence//,也就是该结构总可以分为两个部分:
 +  * 当前的 statement
 +  * 余下的 statement
 +这是一种递归的结构。
 +===Local Assignment===
 +用户自定义的函数是在对应的 local frame 中运行的。local frame 在该函数被调用时创建;函数体中的 ''return'' statement 会起到重定向的作用。函数什么时候结束取决于
 +  * 第一个 ''return'' statement 什么时候被执行
 +  * 返回的值
 +赋值语句可以处于函数内部。任何函数内部的赋值,其绑定信息都存储于local frame,对外部的 name 不造成任何影响。
 +===Conditional statement===
 +<code py>
 +if <expression>:
 +    <suite>
 +elif <expression>:
 +    <suite>
 +else:
 +    <suite>
 +</code>
 +===Iteration===
 +<code py>
 +while <expression>:
 +    <suite>
 +</code>
 +===Testing===
 +