Skip to content

Instantly share code, notes, and snippets.

@kristaph
Last active August 29, 2015 14:06
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 kristaph/e4d1f5fbccab9472d95e to your computer and use it in GitHub Desktop.
Save kristaph/e4d1f5fbccab9472d95e to your computer and use it in GitHub Desktop.
project_multiplication_table
__author__ = 'Kristaph'
"""
http://redd.it/2agwnq
You remember those multiplication tables from elementary school, right? The ones where you choose a number on the
top row and one on the side and see where they meet on the chart? Good. It would be easy enough to just write it
out, but let's try using Python to our advantage.
Goal
Create a program that prints out a multiplication table for the numbers 1 through 9. It should include the numbers
1 through 9 on the top and left axises, and it should be relatively easy to find the product of two numbers. Do
not simply write out every line manually (ie print('7 14 21 28 35 49 56 63') ).
Subgoals
As your products get larger, your columns will start to get crooked from the number of characters on each line.
Clean up your table by evenly spacing columns so it is very easy to find the product of two numbers.
Allow the user to choose a number to change the size of the table (so if they type in 12, the table printed out
should be a 12x12 multiplication table).
"""
#!/usr/bin/python2.7
max_range = int(raw_input("Enter size of table: "))
for i in range(1, max_range + 1):
for j in range(1, max_range + 1):
print '{:5}'.format(i*j),
print ""
@jepio
Copy link

jepio commented Sep 11, 2014

You should change the order of #!/usr/bin/python2.7 and __author__, the hashbang should be first.

@jwasily
Copy link

jwasily commented Sep 19, 2014

wow shocking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment