Skip to content

Commit b7583ff

Browse files
Merge pull request geekcomputers#126 from calmjohnson/master
added a multiplication table
2 parents 7eafe68 + 54bb4ab commit b7583ff

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

multiplication_table.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from sys import argv # import argment variable
2+
3+
script, rows, columns = argv #define rows and columns for the table and assign them to the argument variable
4+
5+
6+
def table(rows, columns):
7+
for i in range(1, int(rows) + 1 ): #it's safe to assume that the user would mean 12 rows when they provide 12 as an argument, b'coz 12 will produce 11 rows
8+
print "\t", i,
9+
10+
print "\n\n"
11+
12+
for i in range(1, int(columns) + 1 ):
13+
print i,
14+
for j in range(1, int(rows) + 1 ):
15+
print "\t",i*j,
16+
print "\n\n"
17+
18+
table(rows, columns)

0 commit comments

Comments
 (0)