In this post, we will write a Python program to display the multiplication table. We’ll use a while-loop, a for-loop, and a function, providing detailed explanations and examples for each approach.

So without any further ado, let’s get started…

## Python Program to Display the Multiplication Table Using while-loop

Let’s start with the algorithm. We will discuss each and every step to write this program and then jump into source code.

### Algorithm

1. Take input from the user (`num`).
2. initialize `i = 1`.
3. `while i<=num` do
`print(f"{num} X {i} = {num*i}") i+=1`
4. End the program

Based on the above algorithm, we now understand how to write this program but Before we delve into the programming part, there are a few essential programming concepts you should be familiar with:

### Source Code

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

i = 1  # initialization
while i<=10:
print(f"{num} X {i} = {num*i}")
i+=1``````

## Python Program to Display the Multiplication Table Using For-loop

Algorithm to write program to display multiplication table using for-loop is very similar to while-loop algorithm there is only syntax changed so let’s seen it.

### Algorithm

1. Take input from the user (`num`).
2. Using for-loop iterate from 1 to 10 (`for i in range(1,11)`).
3. Inside for-loop `print(f"{num} X {i} = {num*i}")`
4. End the program

From the above algorithm, the steps are clear but Before we jump into the programming part few programming concepts you have to know:

### Source Code

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

for i in range(1,11):
print(f"{num} X {i} = {num*i}")``````

## Python Program to Display the Multiplication Table Using Function

### Algorithm

1. define a function with the name mul_table `(def mul_table(n)`).
2. Inside the function do:
`for i in range(1,11):`
` print(f"{num} X {i} = {num*i}")`
3. Outside of the function take input from the user (`num`).
4. at the end call the function with the user input (`mul_table(num)`).

From the above algorithm, the steps are clear but Before we jump into the programming part few programming concepts you have to know:

### Source Code

``````def mul_table(n): # define a function
for i in range(1,11):
print(f"{num} X {i} = {num*i}")

num = int(input("Enter a number: "))
mul_table(num) # calling a function``````

### Output

This covers how we can write a Python program to display the multiplication table using different approaches. I hope you understand all the approaches, and thank you for reading this article.

Hi, I'm Yagyavendra Tiwari, a computer engineer with a strong passion for programming. I'm excited to share my programming knowledge with everyone here and help educate others in this field.