Python program to print multiplication table from n to n

In this totorial we will learn how to write Python program to print multiplication table from n to n ( 1 to 10 or 2 to 20 ).
In this program user is asked to enter start number from which he/she want to start multiplication table. Next enter end number upto which
you want multipleplication table. We are using here for loop. Indentation is important aspect when writing python program.

Source Code:

# python program to print multiplication table from n to n

stnum = int(input("Enter Start number : "))
endnum = int(input("Enter End number : "))
endnum = endnum+1
for i in range(stnum,endnum):
    print("\n\nMULTIPLICATION TABLE FOR %d\n" %(i))
    for j in range(1,11):
        print("%-5d X %5d = %5d" % (i, j, i*j))

Output :

Enter Start number : 2
Enter End number : 5


MULTIPLICATION TABLE FOR 2

2     X     1 =     2
2     X     2 =     4
2     X     3 =     6
2     X     4 =     8
2     X     5 =    10
2     X     6 =    12
2     X     7 =    14
2     X     8 =    16
2     X     9 =    18
2     X    10 =    20


MULTIPLICATION TABLE FOR 3

3     X     1 =     3
3     X     2 =     6
3     X     3 =     9
3     X     4 =    12
3     X     5 =    15
3     X     6 =    18
3     X     7 =    21
3     X     8 =    24
3     X     9 =    27
3     X    10 =    30


MULTIPLICATION TABLE FOR 4

4     X     1 =     4
4     X     2 =     8
4     X     3 =    12
4     X     4 =    16
4     X     5 =    20
4     X     6 =    24
4     X     7 =    28
4     X     8 =    32
4     X     9 =    36
4     X    10 =    40


MULTIPLICATION TABLE FOR 5

5     X     1 =     5
5     X     2 =    10
5     X     3 =    15
5     X     4 =    20
5     X     5 =    25
5     X     6 =    30
5     X     7 =    35
5     X     8 =    40
5     X     9 =    45
5     X    10 =    50
Share This!

Leave a Reply

Your email address will not be published.