Table

Python program to display the multiplication table

Python program to display the multiplication table

In this tutorial, we will discuss Python program to display the multiplication table.

We will learn how to create a multiplication table in a various way in Python language

Program 1

Program to print the multiplication table using for loop in Python

'''multiplication table in Python'''
num=input("Enter the number for multiplication table: ");
#get input from user

#use for loop to iterates 1 times
for i in range(1,11):
    print(num,'x',i,'=',num*i)  #for display multiplication table

When the above code is executed, it produces the following results:

Enter the number for multiplication table:  
12
12x1=12
12x2=24
12x3=36
12x4=48
12x5=60
12x6=72
12x7=84
12x8=96
12x9=108
12x10=112

 

Program to print the multiplication table using while loop in Python

Program 1

num=input("Enter the number for multiplication table: \n");
#get input from user
i=0;
while i<=num:  #use for loop to iterates 1 times
    i+=1;
    print(num,'x',i,'=',num*i)

When the above code is executed, it produces the following results:

Enter the number for multiplication table:
12
12x1=12
12x2=24
12x3=36
12x4=48
12x5=60
12x6=72
12x7=84
12x8=96
12x9=108
12x10=120
12x11=132
12x12=144
12x13=156

 

Suggested for you

For loop in Java language

For loop in C++ language

For loop in C language

For loop in Python language

 

While loop in Java language

While loop in C language

While loop in C++ language

While loop in Python language

Cpp program to multiplication table
Java program to multiply two numbers
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

View Comments

  • for loop ka output : Enter the number for multiplication table: 2
    x 1 = 2
    2 x 2 = 22
    2 x 3 = 222
    2 x 4 = 2222
    2 x 5 = 22222
    2 x 6 = 222222
    2 x 7 = 2222222
    2 x 8 = 22222222
    2 x 9 = 222222222
    2 x 10 = 2222222222

    while loop ka output :
    Enter the number for multiplication table:
    2
    2

    compiler ka output hai
    net pe dalne se phelay check kar liya karo kuch bhi post kar rahe ho

  • Program to print the multiplication table using while loop in Python:

    num1 = int(input('Enter a number:\n'))
    i = 1
    while i < 11:
    print(f'{num1} * {i} = {num1 * i}')
    i = i + 1

    Output:
    3 * 1 = 3
    3 * 2 = 6
    3 * 3 = 9
    3 * 4 = 12
    3 * 5 = 15
    3 * 6 = 18
    3 * 7 = 21
    3 * 8 = 24
    3 * 9 = 27
    3 * 10 = 30

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

2 months ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago