is table row
# is table header
# | is table data cell
# (1) Table opening table
html_table = ""
# (2) Add header row
rows=len(columns[0])
for h in ColumnHeaders:
html_table += ""+h+" | "
html_table += " "
# (3) Add all data rows
for i in range(rows):
html_table += ""
for column in columns:
html_table += ""+str(column[i])+" | "
html_table += " "
# (4) Add the table closing tag
html_table += " "
return html_table
def main(inputs):
m=inputs['multiplier']
r=inputs['range']
col1=[m for i in range(r)]
col2=[i+1 for i in range(r)]
col3=[col1[i]*col2[i] for i in range(r)]
columns=[col1,col2,col3]
ColumnHeaders=["First Number", "Second Number","Product"]
table=build_html_table(columns,ColumnHeaders)
return {"Multiplier": m, "Table":table }
Output:The following is the multiplication table of {{outputs.Multiplier}}
{{ outputs.Table }}
|