Print Multiplication Table

Print the multiplication table for a given number up to 10 (or a user-defined limit).

BeginnerTopic: Basic Python Programs
Back

What You'll Learn

  • Using for loops with range()
  • Printing formatted multiplication tables
  • Allowing a configurable limit

Python Print Multiplication Table Program

This program helps you to learn the fundamental structure and syntax of Python programming.

Try This Code
# Program to print multiplication table of a number

num = int(input("Enter a number: "))
limit = int(input("Enter limit (default 10): ") or 10)

for i in range(1, limit + 1):
    print(f"{num} x {i} = {num * i}")
Output
Enter a number: 5
Enter limit (default 10): 
5 x 1 = 5
5 x 2 = 10
...
5 x 10 = 50

Step-by-Step Breakdown

  1. 1Read the base number and limit from the user.
  2. 2Iterate i from 1 to limit inclusive.
  3. 3Compute num * i inside the loop.
  4. 4Print each line in a formatted way.

Understanding Print Multiplication Table

We use a for loop with range(1, limit + 1) to generate all multipliers.

The default limit is 10, but the user can specify a different upper bound.

Each iteration prints one line of the multiplication table using an f-string.

Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.