File tree Expand file tree Collapse file tree 1 file changed +22
-19
lines changed Expand file tree Collapse file tree 1 file changed +22
-19
lines changed Original file line number Diff line number Diff line change 1- from sys import argv # import argment variable
1+ """
2+ The 'multiplication table' Implemented in Python 3
3+
4+ Syntax:
5+ python3 multiplication_table.py [rows columns]
6+ Separate filenames with spaces as usual.
7+
8+ Updated by Borys Baczewski (BB_arbuz on GitHub) - 06/03/2022
9+ """
10+
11+ from sys import argv # import argument variable
212
313(
414 script ,
818
919
1020def table (rows , columns ):
11- for i in range (
12- 1 , int (rows ) + 1
13- ): # 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
14- print (
15- "\t " ,
16- i ,
17- )
18-
19- print ("\n \n " ) # add 3 lines
20-
21- for i in range (1 , int (columns ) + 1 ):
22- print (i ),
23- for j in range (1 , int (rows ) + 1 ):
24- print (
25- "\t " ,
26- i * j ,
27- )
28- print ("\n \n " ) # add 3 lines
21+ columns = int (columns )
22+ rows = int (rows )
23+ for r in range (1 , rows + 1 ):
24+ c = r
25+ print (r , end = '\t ' )
26+ i = 0
27+ while columns - 1 > i :
28+ print (c + r , end = '\t ' )
29+ c = c + r
30+ i += 1
31+ print ('\n ' )
2932
3033
3134table (rows , columns )
You can’t perform that action at this time.
0 commit comments