# Program to print multiplication table of a given number in python | Code

Using For loop or while loop you can print the multiplication table of a given number in python.

## Example print a multiplication table of a given number

A simple example code takes an input number to show the multiplication of the table.

### Using For loop

We are using “for loop” to iterate the multiplication 10 times. The arguments inside the range() function are (1, 11). Meaning, greater than or equal to 1 and less than 11.

In the first iteration, the loop will iterate and multiply by 1 to the given number. In the second iteration, 2 is multiplied by the given number, and so on.

``````num = int(input("Enter the number: "))

for count in range(1, 11):
print(num, 'x', count, '=', num * count)
``````

Output:

### Using While Loop

We have displayed the multiplication table of variable num.

``````num = int(input("Enter the number: "))
count = 1

while count <= 10:
num = num * 1
print(num, 'x', count, '=', num * count)
count += 1
``````

Output:

Enter the number: 1
1 x 1 = 1
1 x 2 = 2
1 x 3 = 3
1 x 4 = 4
1 x 5 = 5
1 x 6 = 6
1 x 7 = 7
1 x 8 = 8
1 x 9 = 9
1 x 10 = 10

Do comment if you have any doubts or suggestions on this Python table program.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.