摘要: 首先,本文不是总结归纳,只是记录一些有趣的知识点罢了 assert 课堂中在讲授函数,如 from math import pi def area_circle(r): return r * r * pi 但老师提出,当r为-10时,函数不会报错,于是引入assert来检测参数 from math 阅读全文
posted @ 2024-02-29 21:27 陆爻齐 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 观前提示,笔者写的代码答案放在github仓库中,此处仅记录过程与心得 正文 Q1: WWPD: Control Q2: WWPD: Veritasiness Q3: Debugging Quiz! 前三问分别问函数执行结果,python中布尔运算结果,程序报错最可能情况 所以就摘录部分令我印象深刻 阅读全文
posted @ 2024-02-29 19:30 陆爻齐 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 首先,本文不是总结归纳,只是记录一些有趣的知识点罢了 doctest 好东西啊,此前的学习从未看到过,可以在函数的注释中通过特定格式便可书写文档测试,比如 def divide_exact(n, d): ''' Return the quotient and remainder of dividin 阅读全文
posted @ 2024-02-29 19:28 陆爻齐 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 观前提示,笔者写的代码答案放在github仓库中,此处仅记录过程与心得 正文 首先来看下hw的第一道题 Q2: A Plus Abs B Fill in the blanks in the following function for adding a to the absolute value o 阅读全文
posted @ 2024-02-29 19:26 陆爻齐 阅读(12) 评论(0) 推荐(0) 编辑