标签:
一 条件判断
1 if...
2 if...else...
3 if...elif...else...
#coding:utf-8 sex = ‘Male‘ if sex == ‘Male‘: print ‘男‘ elif sex == ‘Femal‘: print ‘女‘ else: print ‘人妖?‘
二 循环语句
1 for...in...
sum = 0 for x in range(1,6): sum = sum + x print ‘sum=%d‘%sum # sum=15
2 while...
n, sum = 5, 0 while n > 0: sum, n = sum + n, n - 1 print ‘sum=%d‘%sum # sum=15
标签:
原文地址:http://www.cnblogs.com/yoleimei/p/4622218.html