sum = 0
x = 1
while x <= 100:
sum += x if x % 2 != 0 else 0
x += 1
print sum
x = 1
while x <= 100:
sum += x if x % 2 != 0 else 0
x += 1
print sum
2016-01-24
print [x*100 + y*10 + z*1 for x in range(1,10) for y in range(0,10) for z in range(1,10) if [x, y, z] == [z, y, x]]
2016-01-23
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.iteritems()]
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.iteritems()]
2016-01-23
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)
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
2016-01-23
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for v in d.values():
sum = sum + v
print sum/ len(d)
sum = 0.0
for v in d.values():
sum = sum + v
print sum/ len(d)
2016-01-23