Python Tutorials

Python Programs

Python Display Multiplication Table


Python Display Multiplication Table

In this tutorial, we will learn how to display the multiplication table of a given number in Python. We will cover the basic loop structure to generate and display the table.


What is a Multiplication Table

A multiplication table is a mathematical table used to define a multiplication operation for an algebraic system. It lists the results of multiplying a number by each of the whole numbers up to a specified limit.


Syntax

The syntax to display the multiplication table of a number in Python is:

for i in range(1, 11):
    print(number, 'x', i, '=', number * i)


Displaying the multiplication table of a number

We can use a for loop to generate and display the multiplication table of a given number.

For example,

  1. Declare a variable number and assign it the number for which you want to generate the multiplication table.
  2. Use a for loop to iterate through the numbers 1 to 10.
  3. In each iteration, multiply the number by the current loop variable i and print the result in the format 'number x i = result'.

Python Program

number = 7

# Display the multiplication table
for i in range(1, 11):
    print(number, 'x', i, '=', number * i)

Output

7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70