# Python Program to Display the Multiplication Table

Given a number the task is to print the multiplication table of the given number from 1 to 10.

Prerequisite:

1)For Loop in python

2)While Loop in python

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.

Examples:

Example 1:

Input:

number=8

Output:

8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80

Example 2:

Input:

number=34

Output:

34 * 1 = 34
34 * 2 = 68
34 * 3 = 102
34 * 4 = 136
34 * 5 = 170
34 * 6 = 204
34 * 7 = 238
34 * 8 = 272
34 * 9 = 306
34 * 10 = 340

## Program to Print the Multiplication Table

Below are the ways to print the multiplication table:

### Method #1:Using for loop

Approach:

To iterate 10 times, we used the for loop in combination with the range() function. The range() function’s arguments are as follows: (1, 11). That is, greater than or equal to 1 and less than 11.

We’ve shown the variable num multiplication table (which is 8 in our case). To evaluate for other values, adjust the value of num in the above program.

Below is the implementation:

# given number
number = 8
# using for loop with range
for i in range(1, 11):
print(number, "*", i, "=", number*i)


Output:

8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80

### Method #2:Using While loop

Approach:

• First we initialize a variable say multiplicationfactor to 1.
• We increment the value of  multiplicationfactor by 1 till the multiplicationfactor is less than or equal to 10.
• Print the multiplication table.

Below is the implementation:

# given number
number = 8
# initializing a variable say multiplication factor to 1
multiplicationfactor = 1
# loop till multiplicationfactor is less than or equal to 10
while(multiplicationfactor <= 10):
print(number, "*", multiplicationfactor, "=", number*multiplicationfactor)
# increment the multiplicationfactor by 1
multiplicationfactor = multiplicationfactor+1


Output:

8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80

Related Programs: