Sep-18-2019, 04:25 AM
Need to know how to format a 12*12 multiplication table to show a multiplication table chart with margins like this:
X 1 2 3 4 5 6 7 8 9 10 11 12
1
2
3
4
5
6
7
8
9
10
11
12
The code to produce the table that fits in the margins above is below:
X 1 2 3 4 5 6 7 8 9 10 11 12
1
2
3
4
5
6
7
8
9
10
11
12
The code to produce the table that fits in the margins above is below:
def main(): rows = int(input("What is the upper bound of multiplication table? ")) print("The multiplication table for 2 to", rows) print() counter = 0 multiplicationTable(rows,counter) def multiplicationTable(rows,counter): size = rows + 1 for i in range(1,size): for nums in range (1,size): value = i*nums print(value,sep=' ',end="\t") counter += 1 if counter%rows == 0: print() else: counter main()