d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59 }
def generate_tr(name, score):
msg='<td>'
if score < 60:
msg = '<td style="color:red">'
return '<tr><td>%s</td>%s%s</td></tr>' % (name, msg, score)
tds = [generate_tr(name, score) for name, score in d.iteritems()]
print '<table border="1">'
print '<tr><th>Name</th><th>Score</th><tr>'
print '\n'.join(tds)
print '</table>'