編寫一個 Python 程序,使用 for 循環列印前 10 個奇數自然數。
print("====The First 10 Odd Natural Numbers====")
for i in range(1, 11):
print(2 * i - 1)
這個 Python 程序使用 while 循環顯示前 10 個奇數自然數。
print("====The First 10 Odd Natural Numbers====")
i = 1
while(i <= 10):
print(2 * i - 1)
i = i + 1
====The First 10 Odd Natural Numbers====
1
3
5
7
9
11
13
15
17
19
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/258003.html