Skip to content

Instantly share code, notes, and snippets.

@Celia-code
Created April 3, 2020 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Celia-code/98de03f496326fdb43c67e60f4b51f78 to your computer and use it in GitHub Desktop.
Save Celia-code/98de03f496326fdb43c67e60f4b51f78 to your computer and use it in GitHub Desktop.
for 條件語句
# 打印 1—100間的偶數
# 首先創建一個1—100的集合,利用range函數,生成(1-100)的區間,所以最後得+1。
num = range(1, 101)
for n in num:
if n % 2 == 0:
print(n)
else:
print("以上數字為1-100之内的偶數")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment