Skip to content

Instantly share code, notes, and snippets.

@ransford
Last active December 20, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ransford/6191463 to your computer and use it in GitHub Desktop.
Save ransford/6191463 to your computer and use it in GitHub Desktop.
multiplication table maker
#!/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>&nbsp;</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