while循环: while 无限循环 count = 1 sum = 0 while True: sum = sum + count count = count + 1 if count == 101: break print(sum) sum = 0 count = 1 while True: if count <101: sum = sum + count print(sum) count = count + 1 else: break 如何终止循环: 1,改变条件 2,break终止循环
一:for 循环 1. 简单的说如果让你输出1到100之间的整数,用while该怎么实现呢? i= : print(i) i+= 看着是不是只有4行,但是有没有更加简单的办法,不妨我们使用for循环来试一下 for i in range(1,101,): print(i) 是不是更加简单,所以说我们总会选择最简单的方法去达到我们的目的九九乘法表:使用while while i <= 9: j = 1 while j <= i: print(str(j) + "*&q
for TAB 和 forr TAB using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 第六天_do_while循环 { class Program { static void Main(string[] args) { ; i <= ; i++) { ; /; ; if (bai*bai*ba
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title() + ", that was a great trick!") print("I can't wait to seee your next trick," + magician.title() + ".\n") print