Study 6 —— while循環

語法
while 條件:
  執行代碼。。。oop

1. #從0打印到100,每循環一次 +1spa

count = 0

while count <= 100 :
  print('Loop: ', count)
  count += 1

2. #打印從1到100的偶數blog

count = 1

while count <= 100 :	
  if count % 2 == 0 :
    print('Even: ', count)
    count += 1

3. #循環打印1-100,第50次不打印值,第60-80次打印對應值的平方class

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
相關文章
相關標籤/搜索