第五节 python控制流
IF语句
#!/usr/bin/python
#Filename e:break.py
number =23
guess = int(raw_input('Enter an interger:'))
if guess == number:
print 'Congratulations, you guessed it.'
print "(but you do not win any prizes!)"
elif guess<number:
print 'No, it is a little higher than that'
else:
print 'No, it is a little lower than that'
print 'Done'
For循环
#for i in range(1,5):
rang = [1,2,3]
for i in rang:
print i;
print "loop is over"
While循环,breaak语句,continue语句
while True:
s = raw_input('Enter something:')
if s == 'quit':
print 'byebye'
break
if len(s)<3:
continue
print 'Input is of sufficient length'

浙公网安备 33010602011771号