print [x*100+y*10+z for x in range(1,101) for y in range(0,101) for z in range(0,101) if x%100==z]
2020-07-14
def generate_tr(name, score):
if score<60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name, score) for name, score in d.items()]
if score<60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name, score) for name, score in d.items()]
2020-07-14
sum = 0
n = 0
while True:
sum = sum + 2**n
n = n+1
if n >=20:
break
print sum
n = 0
while True:
sum = sum + 2**n
n = n+1
if n >=20:
break
print sum
2020-07-14
def move(n,a,b,c):
if n==0:
return
elif n==1:
print a,"-->",c
else:
move(n-1,a,c,b),
print a,"-->",c
move(n-1,b,a,c)
move(4,'a','b','c')
if n==0:
return
elif n==1:
print a,"-->",c
else:
move(n-1,a,c,b),
print a,"-->",c
move(n-1,b,a,c)
move(4,'a','b','c')
2020-07-14
sum1=0
x = 1
while x<98:
x=x+2
sum1+=x
sum=sum1+1
print sum
x = 1
while x<98:
x=x+2
sum1+=x
sum=sum1+1
print sum
2020-07-13
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
n=0
for k, v in d.items():
sum = sum + v
print k,":",v
n=n+1
print 'average', ':', sum/n
sum = 0.0
n=0
for k, v in d.items():
sum = sum + v
print k,":",v
n=n+1
print 'average', ':', sum/n
2020-07-13
sum = 0
sum1=0
x = 1
while x<98:
x=x+2
sum1+=x
sum=sum1+1
print sum
sum1=0
x = 1
while x<98:
x=x+2
sum1+=x
sum=sum1+1
print sum
2020-07-13
L = [75, 92, 59, 68]
sum = 0.0
for nub in L:
sum+=nub
print sum / 4
sum = 0.0
for nub in L:
sum+=nub
print sum / 4
2020-07-13
sum = 0
x = 1
while x <= 100:
if not x % 2 == 0:
sum += x
x += 1
print sum
x = 1
while x <= 100:
if not x % 2 == 0:
sum += x
x += 1
print sum
2020-07-12
def square_of_sum(x):
sum=0
for a in x:
if isinstance(a,int):
b=a*a
sum=b+sum
print "sum:",sum
else:
return "Error Type, Please input int type"
return sum
sum=0
for a in x:
if isinstance(a,int):
b=a*a
sum=b+sum
print "sum:",sum
else:
return "Error Type, Please input int type"
return sum
2020-07-10
#-*-coding:utf-8-*-#
print 7777+999
print"Learn Python in imooc。"
print 100<99
print 0xff==255
print 7777+999
print"Learn Python in imooc。"
print 100<99
print 0xff==255
2020-07-09
print("Learn Python in imooc.");就可以
print("Learn Python in imooc。");就不行
需要在前面添加#-*-coding:utf-8-*-#
print("Learn Python in imooc。");就不行
需要在前面添加#-*-coding:utf-8-*-#
2020-07-09
L = [75, 92, 59, 68]
sum = 0.0
count=0
for val in L:
sum=sum+val
count=count+1
print sum / count
如果有表示数组内元素数量的函数,就可以消灭count了
sum = 0.0
count=0
for val in L:
sum=sum+val
count=count+1
print sum / count
如果有表示数组内元素数量的函数,就可以消灭count了
2020-07-08