导入
使用Edward进行循环
了解循环及其应用。
...
1 / 3
示例阶段 1
while 循环的模板
1while 条件: 2 指令
1while 目标未达成(): 2 移动()
...
循环执行代码
1print(1) 2print(1) 3print(1)
重复打印与计数
1计数器 = 0 2print(1) 3计数器 = 1 4print(1) 5计数器 = 2 6print(1) 7计数器 = 3 8print(1) 9计数器 = 4 10print(1) 11计数器 = 5 12print(1) 13计数器 = 6 14print(1) 15计数器 = 7 16print(1) 17计数器 = 8 18print(1) 19计数器 = 9 20print(1) 21计数器 = 10
1计数器 = 0 2while 计数器 <= 10: 3 print(1)
1计数器 = 0 2while 计数器 <= 10: 3 print(1) 4计数器 = 计数器 + 1
1计数器 = 1 2while 计数器 <= 10: 3 print(1) 4 计数器 = 计数器 + 1
**代码 A** ```Python 计数器 = 0 while 计数器 <= 10: print(计数器) 计数器 = 计数器 + 1 ```
**代码 B** ```Python 计数器 = 0 while 计数器 <= 10: print(计数器) 计数器 = 计数器 + 1 ```
1计数器 = 0 2while 计数器 <= 10: 3 print(计数器) 4计数器 = 计数器 + 1
1计数器 = 1 2while 计数器 <= 10: 3 print(计数器) 4 计数器 = 计数器 + 1
仅对 while 循环的条件做最小改动,使代码输出 1000 个数字。