我对python中docstrings和comments之间的区别感到有点困惑.
在我的课堂上,我的老师介绍了一种被称为"设计方法"的东西,这一系列步骤可以帮助我们学生在Python中更好地绘制和组织编码.根据我的理解,下面是我们遵循的步骤示例 - 这就是呼叫设计配方(引文中的内容):
def term_work_mark(a0_mark, a1_mark, a2_mark, ex_mark, midterm_mark):
''' (float, float, float, float, float) -> float
Takes your marks on a0_mark, a1_mark, a2_mark, ex_mark and midterm_mark,
calculates their respective weight contributions and sums these
contributions to deliver your overall term mark out of a maximum of 55 (This
is because the exam mark is not taken account of in this function)
>>>term_work_mark(5, 5, 5, 5, 5)
11.8
>>>term_work_mark(0, 0, 0, 0, 0)
0.0
'''
a0_component = contribution(a0_mark, a0_max_mark, …Run Code Online (Sandbox Code Playgroud)