您的位置:首页 > 编程语言 > Python开发

第33个python程序:while循环

2016-09-30 15:36 141 查看
[root@mysql1 pshell]# cat ex33.py   

#!/usr/bin/env Python

#-*-coding:utf-8-*-

i=0

numbers=[]

while i<6:

  print "at the top i is %d" % i

  numbers.append(i)

  i=i+1

  print "numnbers now: ", numbers

  print "at the bottom i is %d" % i

print "the numbers: "

for num in numbers:

  print num

[root@mysql1 pshell]# 

[root@mysql1 pshell]# 

[root@mysql1 pshell]# 

[root@mysql1 pshell]# 

[root@mysql1 pshell]# python ex33.py

at the top i is 0

numnbers now:  [0]

at the bottom i is 1

at the top i is 1

numnbers now:  [0, 1]

at the bottom i is 2

at the top i is 2

numnbers now:  [0, 1, 2]

at the bottom i is 3

at the top i is 3

numnbers now:  [0, 1, 2, 3]

at the bottom i is 4

at the top i is 4

numnbers now:  [0, 1, 2, 3, 4]

at the bottom i is 5

at the top i is 5

numnbers now:  [0, 1, 2, 3, 4, 5]

at the bottom i is 6

the numbers: 

0

1

2

3

4

5
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python
相关文章推荐