Skip to content

Instantly share code, notes, and snippets.

@alenbasic
Created June 17, 2016 12:48
Show Gist options
  • Save alenbasic/df317991770d364d73d29ca9f8deba72 to your computer and use it in GitHub Desktop.
Save alenbasic/df317991770d364d73d29ca9f8deba72 to your computer and use it in GitHub Desktop.
A simple timestables generator. Saw an exercise online and thought I'd give it a go. One improvement you could make is to convert the stored values to strings so you could pad smaller values up so everything nicely aligns.
def timestables(size):
table = [[0 for i in range(size)] for i in range(size)]
for j in range(size):
for i in range(size):
table[j][i] = (i+1)*(j+1)
table[i][j] = (i+1)*(j+1)
for line in table:
print line
timestables(15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment