1 # encoding:utf-8 2 3 # 利用For循环和range输出 4 # For循环从大到小输出1-100 5 # For循环从小到大输出100-1 6 # While循环从大到小输出1-100 7 # While循环从小到大输出100-1 8 9 print("For循环从大到小输出100-1") 10 for i in range(0, 100): 11 print(100 - i) 12 13 print("For循环从小到大输出1-100") 14 for i in range(0, 100): 15 print(i + 1) 16 17 print("While循环从大到小输出100-1") 18 19 x = 100 20 while x >= 1: 21 print("{}".format(x)) 22 x -= 1 23 24 print("While循环从小到大输出1-100") 25 x = 1 26 while x <= 100: 27 print("{}".format(x)) 28 x += 1