标签:mic ber str int inf 使用 习题 pytho 练习
Python代码
1 counter = 1 2 while counter < 10: 3 print(counter) 4 counter += 1
输出如下
Python代码
1 counter = 1 2 result = 0 3 while counter < 101: 4 result += counter 5 counter += 1 6 print("sum of 1 to 100:", str(result))
输出如下
Python代码
1 counter = 1 2 print("odd numbers of 1 to 100:") 3 while counter < 101: 4 if counter % 2 == 1: 5 print(counter) 6 counter += 1
输出如下
Python代码
1 counter = 1 2 print("odd numbers of 1 to 100:") 3 while counter < 101: 4 if counter % 2 == 0: 5 print(counter) 6 counter += 1
输出如下
Python代码
1 counter = 1 2 result = 0 3 while counter < 100: 4 if counter % 2 == 1: 5 result += counter 6 elif counter %2 == 0: 7 result -= counter 8 counter += 1 9 print("sum of 1-2+3-4...+99:", str(result))
输出如下
标签:mic ber str int inf 使用 习题 pytho 练习
原文地址:https://www.cnblogs.com/huangwenhao/p/11090495.html