for x in range(1,10):
for y in range(0,10):
if x<y:
print (x*10+y)
for y in range(0,10):
if x<y:
print (x*10+y)
2019-02-15
python定义一个函数规则 :
函数标志 def
函数名 funtionname
非必要的参数
非必要的返回值
例 def funtion_name(L):
return None
函数标志 def
函数名 funtionname
非必要的参数
非必要的返回值
例 def funtion_name(L):
return None
2019-02-15
print [int(str(x)+str(y)+str(z)) for x in range(1,10) for y in range(10) for z in range(10) if x==z]
第一位不可以从0开始,后面两位可以为0,把x,y,z转换成字符串,方便操作,最后整体再转换为int,即:int(str(x)+str(y)+str(z))
第一位不可以从0开始,后面两位可以为0,把x,y,z转换成字符串,方便操作,最后整体再转换为int,即:int(str(x)+str(y)+str(z))
2019-02-14
我真的是服了python的设计者,这个语法糖给的莫名其妙的,返回一个tuple就老老实实写括号不好吗,偏偏又省略了,这种容易让人产生错觉的设计,也就是他老人家能甘之若饴了
2019-02-14
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.items():
sum = sum + v
score = sum/len(d)
print k,':',v
print 'average', ':', score
sum = 0.0
for k, v in d.items():
sum = sum + v
score = sum/len(d)
print k,':',v
print 'average', ':', score
2019-02-13
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for num in d.values():
sum += num
print sum / len(d)
sum = 0.0
for num in d.values():
sum += num
print sum / len(d)
2019-02-13
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for index, name in enumerate(L,start=1):
print index, '-', name
for index, name in enumerate(L,start=1):
print index, '-', name
for score in d.itervalues():
if score>60:
tds = ['<tr><td>%s</td><td>%s</td></tr>'%(name,score) for name ,score in d.iteritems()]
else:
tds = ['<tr><td>%s</td><td style="color:red">%s</td></tr>'%(name,score) for name, score in d.iteritems()]
if score>60:
tds = ['<tr><td>%s</td><td>%s</td></tr>'%(name,score) for name ,score in d.iteritems()]
else:
tds = ['<tr><td>%s</td><td style="color:red">%s</td></tr>'%(name,score) for name, score in d.iteritems()]
2019-02-13
if score>60:
tds = ['<tr><td>%s</td><td>%s</td></tr>'%(name,score) for name ,score in d.iteritems()]
else:
tds = ['<tr><td>%s</td><td style="color:red">%s</td></tr>'%(name,score) for name, score in d.iteritems()]
tds = ['<tr><td>%s</td><td>%s</td></tr>'%(name,score) for name ,score in d.iteritems()]
else:
tds = ['<tr><td>%s</td><td style="color:red">%s</td></tr>'%(name,score) for name, score in d.iteritems()]
2019-02-13