打印出0-10之间的所有偶数:
方法1:
1 num = 2 2 while num < 10: 3 print(num) 4 num += 2
方法2:
1 num = 1 2 while num < 10: 3 if num%2 == 0: 4 print(num) 5 num +=1
打印出0-10之间的所有奇数:
方法1:
1 num = 1 2 while num < 10: 3 print(num) 4 num += 2
方法2:
1 num = 0 2 while num < 10: 3 if num%2 == 1: 4 print(num) 5 num +=1
死循环:
1 num = 1 2 while num < 10: 3 print(num)