Skip to content

Instantly share code, notes, and snippets.

@jburgy
Created November 10, 2023 11:36
Show Gist options
  • Select an option

  • Save jburgy/3a67e04df3af71e9fd48a0af92cdc14f to your computer and use it in GitHub Desktop.

Select an option

Save jburgy/3a67e04df3af71e9fd48a0af92cdc14f to your computer and use it in GitHub Desktop.
Semantic html to help a child memorize their times table
row = "<tr><th>{}</th>{}</tr>".format
cell = (
'<td><input type="text" required minlength=1 maxlength=3'
' size=1 pattern={}></td>'.format
)
print(
"""<html lang="en">
<head>
<title>Multiplicatino Table</title>
</head>
<style>
input:invalid {{ color: #c00; }}
</style>
<body>
<table>
<thead>
<tr>
<th>&times;</th>
{}
</tr>
</thead>
<tbody>
{}
</tbody>
</table>
</body>
</html>
""".format(
"\n".join(f"<th>{i}</th>" for i in range(1, 13)),
"\n".join(
row(i, "\n".join(cell(i * j) for j in range(1, 13))) for i in range(1, 13)
),
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment