Dynamic python program to display a multiplication table



This program displays a multiplication table of any number entered by the user. The programming concept used is the for loop and input and output function. Inside the for loop, I have used the range() function to control the number of iteration till 12. So, we can then generate a multiplication table of any number from 1 to 12.

Code:

num = int(input("Multiplication table of number: "))
print("\nMultiplication Table for number", num)
print("--------------------------------")
for i in range(1,13):
    print(num,"*", i, "=", num * i)

Output:

>>>
Multiplication table of number: 7

Multiplication Table for number 7
--------------------------------
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70
7 * 11 = 77
7 * 12 = 84

>>>
Multiplication table of number: 13

Multiplication Table for number 13
--------------------------------
13 * 1 = 13
13 * 2 = 26
13 * 3 = 39
13 * 4 = 52
13 * 5 = 65
13 * 6 = 78
13 * 7 = 91
13 * 8 = 104
13 * 9 = 117
13 * 10 = 130
13 * 11 = 143
13 * 12 = 156