Python Program to print Multiplication table of a given number


In this post, let's learn how to generate multiplication table of a given number.

Python program to generate multiplication table:

import sys
num = int(sys.stdin.readline()) # Take input from User
for i in range(1, 11): # Iterate for loop for 10 times
   print(num, 'x', i, '=', num*i)

Result

Consider you have provided 16 as your input, then below is the output

16 * 1 = 16 
16 * 2 = 32 
16 * 3 = 48 
16 * 4 = 64 
16 * 5 = 80 
16 * 6 = 96 
16 * 7 = 112 
16 * 8 = 128 
16 * 9 = 144 
16 * 10 = 160

If you want to generate the multiplication table to other range like 20, provide range(1, 21) in the for loop which generates the output as below.

16 * 1 = 16 
16 * 2 = 32 
16 * 3 = 48 
16 * 4 = 64 
16 * 5 = 80 
16 * 6 = 96 
16 * 7 = 112 
16 * 8 = 128 
16 * 9 = 144 
16 * 10 = 160 
16 * 11 = 176 
16 * 12 = 192 
16 * 13 = 208 
16 * 14 = 224 
16 * 15 = 240 
16 * 16 = 256 
16 * 17 = 272 
16 * 18 = 288 
16 * 19 = 304 
16 * 20 = 320

You can generate multiplication table in Python for any other integer Online here by providing the integer value in the stdin section.