Repository Details
Shared by
HelloGitHub Rating
0 ratings
一份以代码和注释方式讲解 Python 的免费教程
Past 7 days Received 38 stars ✨
Use arrow keys to explore dates, Home and End for the first and last date, Escape to dismiss.| Date | Star | Daily change |
|---|---|---|
| 周二 | 18,507 | — |
| 周三 | 18,510 | +3 |
| 周四 | 18,512 | +2 |
| 周五 | 18,511 | -1 |
| 周六 | 18,509 | -2 |
| 周日 | 18,525 | +16 |
| 周一 | 18,545 | +20 |
18.5k
Stars
Yes
Chinese
Python
Language
No
Active
17
Contributors
44
Issues
No
Organization
None
Latest
3k
Forks
MIT
License
一份以代码和注释方式讲解 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
```
Comments
Rating:
No comments yet