Files
2025PY/day08/02-循环的意义.py
2025-05-22 16:50:44 +08:00

27 lines
764 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.
# 一.循环的意义
# 循环在程序中同判断一样,也是广泛存在的,是非常多功能实现的基础
# 例如输出100次内容
print('你好,世界1')
print('你好,世界2')
print('你好,世界3')
print('你好,世界4')
print('你好,世界5')
print('你好,世界6')
print('你好,世界7')
print('你好,世界8')
print('你好,世界9')
print('你好,世界10')
# 上面的写法如果是100次非常不方便可以通过循环进行优化
# 二.python里面的循环语句
# 1、while循环
# 2、for...in 循环
# 三.循环的组成
# 1、定义循环的关键字(while for in)
# 2、限制条件(终止条件)
# 3、循环体(满足条件执行的代码)
# 四.死循环
# 无法靠自身条件终止的代码的循环