1 #while输出数字
2 i = 0
3 while True:
4 print(i)
5 i+=1
6
7 #如果不设置条件来结束循环,那么循环将一直执行下去
8 if i == 10:
9 break
10
11 #while循环输出九九乘法表
12 j = 1
13 while j<=9:
14 n =1
15 while n<=j:
16 #%-2d表示靠左对齐并占两个字符,end=‘ ‘ 表示不换行’’
17 print("%d*%d=%-2d"%(n,j,n*j,end=' ')
18
19 #猜年龄
20 count = 0
21 age = 28
22 while True:
23 _age = int(input("年龄:"))
24 if _age == age:
25 print("you got it")
26 break
27 elif _age <age:
28 print("saller")
29 else:
30 print("bigger")
31 else:
32 print("failed")
33 '''
34 此处else相当于if
35 if count == 3:
36 print("failed")
37 '''