python入门之语句,包括if语句、while语句、for语句,供python初学者参考。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/ / if 语句例子 name = 'peirong' ; if name = = 'peirong' : print 'this is peirong' ; elif name = = 'maojun' : print 'this is maojun' ; else : print 'others' ; / / while 语句 i = 0 ; a = range ( 10 ); while i < a.__len__(): print i; i = i + 1 ; / / for 语句 a = range ( 1 , 10 ); for i in a: print i; else : print 'The for loop is over!' / / continue 语句 a = range ( 1000 ) for i in a: if i % 3 = = 0 : print 'chuyi 3 yu 0 ' ; elif i % 3 = = 1 : print 'chuyi 3 yu 1 ' ; else : continue |