Displaying a Multiplication Table

A code to display the Multiplication Table of a specific number.

Welcome to the code! This code is for all the geeks out there who love to play with numbers. However, this is a a simple Python code to display the Multiplication table we all once spent hours learning.

In this code, the user is asked for a number to show its multiplication table and the user can also choose upto which number the multiplication table has to be displayed.

Note: Loved the post? You too can publish your article on “Python for fun” which will be loved by millions. Contribute an article!

					num = int(input("Enter the Multiplication Table you want to display: "))

length = int(input("Enter upto which number do you want to display the multiplication table: "))

for i in range (length+1):
    print(num, "X", i, "=", num*i)				
3 2 votes
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
1 year ago

Using Tabulate module will make it look prettier

from tabulate import tabulate

num = int(input("Enter a number for its table: "))
data = []

for x in range(1,11):
    globals()['val' + str(x)] = x * num
    globals()['list' + str(x)] = [num, "x", x, "="]
    globals()['list' + str(x)].append(globals()['val' + str(x)])
    data.append(globals()['list' + str(x)])
print(tabulate(data, tablefmt='grid'))