Created
June 20, 2009 01:47
-
-
Save twopoint718/132995 to your computer and use it in GitHub Desktop.
multiplication table in python
This file contains hidden or 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
| import math | |
| def multtab(n): | |
| width = 1 + int(math.ceil(math.log(n)/math.log(10))) | |
| format_str = '%' + str(width) + "d" | |
| for row in range(1,n+1): | |
| for col in range(1,n+1): | |
| print format_str % (row * col), | |
| if __name__ == "__main__": | |
| multtab(9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment