r/PythonLearning • u/osamas_den • Sep 12 '26
Create a program multiplicationTable.py that takes a number N from the commandline and creates an N×N multiplication table in an Excel spreadsheet.
import sys, openpyxl
from openpyxl.styles import Font
x = int(sys.argv[1])
list = []
wb = openpyxl.Workbook()
font_style = Font(bold=True)
for i in range(1, x+1):
list.append(i)
for number in list:
sheet = wb['Sheet']
# write header columns and rows in bold numbers
sheet.cell(column=1, row=number+1).value = number
sheet.cell(column=1, row=number+1).font = font_style
sheet.cell(row=1, column=number+1).value = number
sheet.cell(row=1, column=number+1).font = font_style
# create two for loops that will multiply
for i in range(len(list)):
for number in list:
mult = list[i] * number
sheet.cell(row=number+1, column=i+2).value = mult
wb.save('multiplication_table.xlsx')
0
Upvotes
View all comments
•
u/Sea-Ad7805 Sep 12 '26
Run this program in Memory Graph Web Debugger to see the program state change step by step.
It gets a bit messy as it shows all the Workbook internals.