Python Program to Display Multiplication Table

Last Updated:

Using for Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using for loop

Example

Python Compiler
table = 9 length = 10 print("Multiplication table: %d" % table) for i in range(1, length+1): print("%2d * %d = %d" %(i, table, i*table))

Using while Loop

In the following example, we will create and display the Multiplication Table for the given number (9) using while loop

Example

Python Compiler
table = 9 length = 10 i = 1 print("Multiplication table: %d" % table) while(i <= length): print("%2d * %d = %d" %(i, table, i*table)) i += 1

Display Customized Table

In the following example, we will display the table according to the given table number and table length.

Example

Python Compiler
table = int(input("Enter the table number: ")) length = int(input("Enter the table length: ")) print("\nMultiplication table: %d" % table) for i in range(1, length+1): print("%2d * %d = %d" %(i, table, i*table))

Share this Page

Meet the Author