python while循环语句是什么?

如题所述

python while循环语句是:通过while 循环求1~100所有整数累加的和。

result=0。

i=0。

while i <=100。

result+=i。

i+=1。

 print('\t第%d次计算结果是:%d' % (i, result))。

 print('1~100所有整数累加的和为:%d' % result)。

实例:

/usr/bin/python。

 count=0。

while (count < 9)。

print 'The count is:', count。

count = count+1。

 print "Good bye!"。

运行实例:

以上代码执行输出结果。

The count is:0。

The count is:1。

The count is:2。

The count is:3。

The count is:4。

The count is:5。

The count is:6。

温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜