读书人

Python 入门教程 13 - Loops

发布时间: 2013-10-01 12:15:56 作者: rapoo

Python 入门教程 13 ---- Loops


第一节

1 介绍了另外一种循环while循环

2 while循环的结构如下

while condition:

statement


第二节

1 while循环的练习,写一个while循环,打印出1~10的平方数

fruits = ['banana', 'apple', 'orange', 'tomato', 'pear', 'grape']print 'You have...'for f in fruits:    if f == 'tomato':        print 'A tomato is not a fruit!' # (It actually is.)        break    print 'A', felse:    print 'A fine selection of fruits!'



读书人网 >perl python

热点推荐