Program to Display Multiplication Table using while loop in Python

Program to Display Multiplication Table using while loop in Python. Program uses input command, variable assignment, print statements and while loop. This program is good to know for beginners, class 11,12 and B Tech Computer Science students .Download source code.

Program to Display Multiplication Table using while loop in Python

We will print the multiplication table of any number (from 1 to 10) by using the while loop.

Source code: Program to Display Multiplication Table using while loop in Python

number = int(input ("Enter the number of which the user wants to print the multiplication table: "))      
count = 1    
# we are using while loop for iterating the multiplication 10 times      
print ("The Multiplication Table of: ", number)    
i=0
while count <= 10:
    
    number = number * 1    
    print (number, 'x', i, '=', number * count)    
    count += 1
    i=i+1

Download Source code : For Download Click on the below Button

Step-wise Source code Explanation

Step 1 – Input the number which multiplication table has to be printed
number = int(input (“Enter the number of which the user wants to print the multiplication table: “))
Step 2 – A variable count is initialized to 1.
count = 1
Step 3 – Multiplication table is printed
print (“The Multiplication Table of: “, number)
Step 4 – While loop is used to print the multiplication table
while count <= 10:
number = number * 1
print (number, ‘x’, i, ‘=’, number * count)
count += 1

Output :

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
 RESTART: C:/Users/ARCHIT/AppData/Local/Programs/Python/Python37-32/test1.py 
Enter the number of which the user wants to print the multiplication table: 8
The Multiplication Table of:  8
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
8 x 4 = 32
8 x 5 = 40
8 x 6 = 48
8 x 7 = 56
8 x 8 = 64
8 x 9 = 72
8 x 10 = 80
>>> 

Output Explanation :

The number is input that has to be multiplied in the table
The Multiplication Table of: 8

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

Conclusion:

The program is running fine.

Thank you for reading and learning from this post. Program uses input command, variable assignment, print statements and while loop. This program is good to know for beginners, class 11,12 and B Tech Computer Science students. For more program and practical file of 11 and 12.

Python Programs Archives – CS Study

Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study

Computer Science Practical file for class 12 Term-2 – CS Study

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version