Last active
December 20, 2015 20:38
-
-
Save ransford/6191463 to your computer and use it in GitHub Desktop.
multiplication table maker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
MAX = 20 # this many rows and columns | |
xs = range(1, MAX+1) | |
print(""" | |
<html> | |
<head> | |
<style type="text/css"> | |
table { border: 1px solid black; } | |
td { text-align: center; padding: 5px } | |
* { font-family: Helvetica, sans-serif; font-size: large; } | |
th { font-size: x-large; } | |
</style> | |
</head> | |
<body> | |
<table> | |
""") | |
print('<tr><th> </th>') | |
for x in xs: | |
print('<th>{}</th>'.format(x)) | |
print('</tr>') | |
for x in xs: | |
print('<tr><td><strong style="font-size: x-large;">{}</strong></td>'.format(x)) | |
for y in xs: | |
if (x == y): | |
print('<td><strong>{}</strong></td>'.format(x*y)) | |
else: | |
print('<td>{}</td>'.format(x*y)) | |
print('</tr>') | |
print('</table></body></html>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment