def generate_tr(name, score):
if (score < 60):
return '<tr><td style="color:red">%s</td><td>%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.iteritems()]
if (score < 60):
return '<tr><td style="color:red">%s</td><td>%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.iteritems()]
2018-04-15
def move(n, a, b, c):
if 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 == 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')
2018-04-15
L = []
n = 1
while n <= 100:
L.append(n*n)
n = n + 1
print sum(L)
n = 1
while n <= 100:
L.append(n*n)
n = n + 1
print sum(L)
2018-04-15
sum = 0
x = 0
while True:
print x
x = x + 1
if x > 100:
break
if x % 2 == 1:
sum += x
else:
continue
print x
print sum
x = 0
while True:
print x
x = x + 1
if x > 100:
break
if x % 2 == 1:
sum += x
else:
continue
print x
print sum
2018-04-15
# -*- coding:UTF-8 -*-
# python 加法 十进制加十六进制
print(45678 + 0x12fd2)
# python 输出 在immoc学习python
print('learn Python in imooc')
# python 输出100小于99 false
print(100 < 99)
# python 输出十六进制255 等于十进制255 true
print(0xff == 255)
# python 加法 十进制加十六进制
print(45678 + 0x12fd2)
# python 输出 在immoc学习python
print('learn Python in imooc')
# python 输出100小于99 false
print(100 < 99)
# python 输出十六进制255 等于十进制255 true
print(0xff == 255)
2018-04-14
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d.items())
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d.items())
2018-04-14
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for v in d.values():
sum += v
print sum/len(d.values())
sum = 0.0
for v in d.values():
sum += v
print sum/len(d.values())
2018-04-14
print 45678 + 0x12fd2
print 'Learn Python in imooc'
print 100 < 99
print 0xff == 255
print 'Learn Python in imooc'
print 100 < 99
print 0xff == 255
2018-04-14
虽然pop()方法总是删掉list的最后一个元素,并且它还返回这个元素,但是 第一个例子的L.pop()并不会打印'Paul'。
print L.pop()才会打印出Paul
print L.pop()才会打印出Paul
2018-04-14