rows=10 # Multiplication table up to 10
columns=10 # Number of columns
# rows,columns=10,10
for i in range(1,rows+1):
for j in range(1,columns+1):# inner for loop
c=i*j
print("{:2d} ".format(c),end='')
print("\n") # line break
rows=10 # Multiplication table up to 10
columns=10 # column values
i,j=1,1 # start from 1 table
while i<= 10:
while j <= 10:
c=i*j
print("{:2d} ".format(c),end=' ')
#print(c,end=' ')
j=j+1
i,j=i+1,1 # i value to increase and reset j value
print("\n") # line break
Multiplication table based on user input
Here no need to use nested loop as one for loop is enough.
i=int(input("Enter a number :"))
columns=12
for j in range(1,columns+1):
c=i*j
print("{:2d} ".format(c),end='')
Output
Enter a number :20
20 40 60 80 100 120 140 160 180 200 220 240