本系列为加州伯克利大学著名 Python 基础课程 CS61A 的课堂笔记整理,全英文内容,文末附词汇解释。
目录
06 If Statements and Call Expressions
08 Function Decorator —— @tracel
01 Designing Functions
A function's domain(定义域) is the set of all inputs it might possibly take as arguments.
A function's range(范围) is the set of output values it might possibly return.
A pure function's behavior is the relationship it creates between input and output.
A Guide to Design Function:
① Give each function exactly one job. 分工
② Don't repeat yourself. Implement a process just one, but execute it many times. 调用
③ Define functions generally. 泛化
02 Functional Abstractions
identically 同一地;相等地
03 Chosing Names
Names typically don't matter for correctness but they matter a lot for composition (组成). They should convey(表达) the meaning or purpose of the values to which they are bound.
Function names typicall