Last active
August 29, 2015 14:06
-
-
Save kristaph/e4d1f5fbccab9472d95e to your computer and use it in GitHub Desktop.
project_multiplication_table
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
__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 "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should change the order of
#!/usr/bin/python2.7
and__author__
, the hashbang should be first.