Python Program to Display the Multiplication Table

This Python example will cover the Program to Display the multiplication Table.

1. What is a Multiplication Table?

Multiplication tables are a common staple in mathematics education and a simple yet effective tool for developing arithmetic skills. In this article, we’ll look at a Python program that displays the multiplication table of a given number. The program takes an input number, and then using a loop, it prints the multiplication table of that number up to a specified range.

Example:
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
8 x 4 = 32
8 x 5 = 40

Some of the topics which will be helpful for understanding the program implementation better are:

Let’s go through each of the implementation methods one by one.


2. Python Program to Display the Multiplication Table

This program can be run in any Python environment, such as the Python IDLE, and it will prompt the user for the start and end of the interval. It will then print all the Armstrong numbers within that interval.

# Python Program to display multiplication table
def multiplication_table(number, range_num):
  for i in range(1, range_num+1):
    print(number, "x", i, "=", number*i)


number = int(input("Enter the number for which you want the multiplication table: "))
range_num = int(input("Enter the range for the multiplication table: "))
multiplication_table(number, range_num)
Output
Enter the number for which you want the multiplication table: 8
Enter the range for the multiplication table: 5
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
8 x 4 = 32
8 x 5 = 40

2.1. Explanation of the program

  • The function multiplication_table takes two arguments: number and range_num.
  • The for loop starts from 1 and runs up to range_num + 1.
  • Inside the loop, we print the multiplication of the number and i, which is the current iteration value of the loop.
  • We then ask the user to enter the number for which they want the multiplication table and the range of the table.
  • Finally, we call the multiplication_table function with the given input.

3. Conclusion

This program to display multiplication table is a simple and easy-to-understand example of using loops in Python. It’s an excellent starting point for those who are new to programming or looking to improve their Python skills. Give it a try and see how you can modify it to make it even more useful!


Helpful Links

Please follow the Python tutorial series or the menu in the sidebar for the complete tutorial series.

Also for examples in Python and practice please refer to Python Examples.

Complete code samples are present on Github project.

Recommended Books


An investment in knowledge always pays the best interest. I hope you like the tutorial. Do come back for more because learning paves way for a better understanding

Do not forget to share and Subscribe.

Happy coding!! ?

Recommended -

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Index