下拉刷新
项目详情
navbar_avatar分享
repo_avatar
HelloGitHub 评分
0 人评分
一份以代码和注释方式讲解 Python 的免费教程
开源MIT
认领
收藏
分享
16.4k
星数
中文
Python
主语言
活跃
15
贡献者
25
Issues
组织
最新版本
3k
Forks
MIT
协议
更多
一份以代码和注释方式讲解 Python 的免费教程。每个 Python 基础语法和知识点都采用可以运行的代码为例讲解,再配上适当的注释和参考资料,让你快速上手 Python。此项目不仅可以当做学习 Python 的资料,还可以留着做为速查表 ```python """WHILE statement @see: https://docs.python.org/3/tutorial/controlflow.html @see: https://docs.python.org/3/reference/compound_stmts.html#the-while-statement The while loop executes as long as the condition remains true. In Python, like in C, any non-zero integer value is true; zero is false. The condition may also be a string or list value, in fact any sequence; anything with a non-zero length is true, empty sequences are false. The test used in the example is a simple comparison. The standard comparison operators are written the same as in C: < (less than), > (greater than), == (equal to), <= (less than or equal to), >= (greater than or equal to) and != (not equal to). """ def test_while_statement(): """WHILE statement""" # Let's raise the number to certain power using while loop. number = 2 power = 5 result = 1 while power > 0: result *= number power -= 1 # 2^5 = 32 assert result == 32 ```
收录于:
第 62 期
标签:
教程
小抄
Python

评论

评分:
暂无精选评论