controlFlow
if,elif,else
for用于对集合(列表或者元组)或者迭代器进行迭代
sequence = [1,2,None,2,None]
total = 0
for i in sequence:
if i is not None:
total = total + i
print "It's ",i,"and total is ",total
print total```
x = 256
total = 0
while x > 0:
if total > 500:
break
total = total + x
print "total is ",total,"and x is ",x
x = x // 2```
range()产生间隔平均的整数
print range(10)
print range(0,20,3)
seq = range(1,5,1)
print seq
for i in range(len(seq)):
val = seq[i]
print val```
#xrange()函数不会预先产生所有的值并且将他们保存到列表中,而是返回一个逐个产生整数的迭代器
sum = 0
for i in xrange(10000):
if i % 3 ==0 or i % 5 ==0 :
sum += i
print sum```
三元表达式
print 'non-negative' if x > 0 else "negative"```