第五天Python學習記錄
阿新 • • 發佈:2018-01-18
學習記錄 pre eve 記錄 語句 pytho spa 結束 就是
while循環
#第50次不打印,第60-80次打印對應值的平方
1 count = 0 2 3 while count <= 100: 4 if count == 50: 5 pass 6 elif count >= 60 and count <=80: 7 print(count*count) 8 else: 9 print("loop ",count) 10 11 count += 1 12 13 print("------loop is ended-------")
Dead Loop(死循環)
count = 0 while True:#True本身就是真 print("forever-------",count) count += 1
break 用於完全結束一個循環,跳出循環體執行魂環後面的語句 continue 只是終止本次循環,接著執行後面的循環
count = 0 while count <= 100: print("loop ",count) if count == 5: break count += 1 print("------out of loop-------")
count = 0while count <= 100: print("loop ",count) if count == 5: continue count += 1 print("------out of loop-------")
0-100循環,跳過6到94
count = 0 while count <= 100: count += 1 if count > 5 and count < 95: continue print("loop ",count) print("------out of loop-------")
第五天Python學習記錄