Python Forum
Multiplication Table number margins
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiplication Table number margins
#1
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:
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()
Reply


Messages In This Thread
Multiplication Table number margins - by CJ707 - Sep-18-2019, 04:25 AM
RE: Multiplication Table number margins - by CJ707 - Sep-18-2019, 01:51 PM
RE: Multiplication Table number margins - by CJ707 - Sep-18-2019, 02:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiplication Table code alexsendlegames100 3 1,420 Jun-06-2022, 09:45 AM
Last Post: Gribouillis
  Try to solve GTG multiplication table problem. Frankduc 6 2,073 Jan-18-2022, 08:26 PM
Last Post: Frankduc
  Need help with my Python code (Multiplication) NeedHelpPython 2 1,726 Oct-04-2021, 12:09 PM
Last Post: Pedroski55
  Creating table in MySQL db with decimal number issue dangermaus33 7 4,979 Nov-20-2020, 10:40 PM
Last Post: dangermaus33
  List conversion and multiplication johnkyp 5 3,213 Jan-02-2020, 08:20 AM
Last Post: perfringo
  Matrix Multiplication Issue VIJENDRA 1 1,900 Dec-19-2019, 06:16 PM
Last Post: Gribouillis
  Multiplication between a list and a variable doug2019 2 2,197 Oct-08-2019, 04:10 AM
Last Post: doug2019
  multiplication by successive addition Zebrol 1 3,560 Sep-14-2019, 05:37 PM
Last Post: ichabod801
  Tracing a multiplication table w/ Python trace() NationalRex22 0 1,775 Jun-11-2019, 03:31 AM
Last Post: NationalRex22
  float multiplication - unexpected output inesk 3 3,389 Dec-11-2018, 10:59 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020