Files
2025PY/day08/03-while循环.py
2025-05-22 16:50:44 +08:00

23 lines
476 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 一、while循环
# 语法
"""
while 判断条件:
满足条件执行语句
...
"""
# 注意
# 初始值
# while + 限制条件
# 满足条件执行的循环体
# 初始值的迭代(累加累减)
# 案例
# 打印100-200之间是有能被3和7整除的数
num = 100 # 初始值
while num <= 200: # 条件1100-200
# 条件2能被3和7整除
if(num % 3 == 0 and num % 7 == 0):
print(num) # 打印结果
num += 1 # 累加 初始值的迭代