d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
def ckeck_num(name,score):
tempStr=( '<td style="color:red">' if (score<60) else '<td>')
str='<tr><td>%s</td>%s%s</td></tr>' % (name,tempStr,score)
return str
tds=[ckeck_num(name,score) for name,score in d.items()]
def ckeck_num(name,score):
tempStr=( '<td style="color:red">' if (score<60) else '<td>')
str='<tr><td>%s</td>%s%s</td></tr>' % (name,tempStr,score)
return str
tds=[ckeck_num(name,score) for name,score in d.items()]
2018-07-06
print [i + j*10 + k*100 for i in range(1,10) for j in range(0,10) for k in range(0,10) if i==k] #个位i是不能有0,这样会变成1位或者2位数字,及三位数字必须用i + j*10 + k*100构成
2018-07-06
sum = 0
x = 1
while x < 100:
if x % 2 == 1:
sum += x
x=x+2
print sum
x = 1
while x < 100:
if x % 2 == 1:
sum += x
x=x+2
print sum
2018-07-06
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
2018-07-06
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
aver = 0.0
for score in d.values():
sum +=score
aver = sum/len(d)
print aver
sum = 0.0
aver = 0.0
for score in d.values():
sum +=score
aver = sum/len(d)
print aver
2018-07-06
# -*- coding: utf-8 -*-
#先列出要计算面积的圆的半径list
L = [12.3,9.01,73.1]
#写运算规定
def area_of_circle(x):
s = 3.14 * x * x
print s
#应用规定area_of_circle(x)
for x in L:
area_of_circle(x)
#先列出要计算面积的圆的半径list
L = [12.3,9.01,73.1]
#写运算规定
def area_of_circle(x):
s = 3.14 * x * x
print s
#应用规定area_of_circle(x)
for x in L:
area_of_circle(x)
2018-07-06
def firstCharUpper(s):
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2018-07-06