What & How & Why

差别

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

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
后一修订版两侧同时换到之后的修订记录
cs:fundamental:cs61a:week_1 [2023/09/26 03:59] – [Documentation] codingharecs:fundamental:cs61a:week_1 [2023/09/26 04:20] – [Control] codinghare
行 244: 行 244:
 </code> </code>
 还有一类以 ''#'' 起头的信息被称为 //Comments// 还有一类以 ''#'' 起头的信息被称为 //Comments//
-====Control==== 
 [[https://peps.python.org/pep-0257/|Docstring Conventions]] [[https://peps.python.org/pep-0257/|Docstring Conventions]]
 +====Control statement====
 +===statement===
 +//statement// 与 //expression// 在本质上有不同:
 +  * 我们评估(//evaluate//) expression 
 +  * 我们执行(//execute//)statement
 +//statement// 意味着应用更改:比如赋值,返回等等。//exrepssion// 在被评估的时候也可以被视作 //statement//,但其生成的结果会丢失。比如:
 +<code py>
 +>>> def square(x):
 +        mul(x, x) # Watch out! This call doesn't return a value
 +</code>
 +如果希望应用修改(返回返回值),则需要使用 ''return'' statement:
 +<code py>
 +>>> def square(x):
 +        return mul(x, x)
 +</code>
 +==Compound Statements==