編寫一個 Python 程序,使用 for 循環以相反的順序打印前 10 個自然數。
print("====The First 10 Natural Numbers in Reverse====")
for i in range(10, 0, -1):
print(i)這個 Python 程序使用 while 循環以逆序或降序顯示前 10 個自然數。
print("====The First 10 Natural Numbers in Reverse====")
i = 10
while(i >= 1):
print(i)
i = i - 1====The First 10 Natural Numbers in Reverse====
10
9
8
7
6
5
4
3
2
1原創文章,作者:ED26H,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/127701.html
微信掃一掃
支付寶掃一掃