python的循环语句等

时间:2015-05-14 11:36:20   收藏:0   阅读:110
names = [‘Michael‘, ‘Bob‘, ‘Tracy‘]
for name in names:
    print name




sum = 0
for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
    sum = sum + x
print sum




sum = 0
n = 99
while n > 0:
    sum = sum + n
    n = n - 2
print sum




以上这三种就已经够用了
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!