Study 6 —— while循环
语法
while 条件:
执行代码。。。
1. #从0打印到100,每循环一次 +1
count = 0 while count <= 100 : print('Loop: ', count) count += 1
2. #打印从1到100的偶数
count = 1 while count <= 100 : if count % 2 == 0 : print('Even: ', count) count += 1
3. #循环打印1-100,第50次不打印值,第60-80次打印对应值的平方
count = 1 while count <= 100: if count == 50: pass elif count >= 60 and count <= 80: print('Value: ', count ** 2) else: print('Value: ', count) count += 1
4. 死循环
count = 0 while True: print('Value', count) count += 1