Created
June 17, 2016 12:48
-
-
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.
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
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