Write a Python Program to Print Multiplication Table using For Loop and While Loop with an example.
Python Program to Print Multiplication Table using For loop
This Python program prints the multiplication table from 8 to 10 using For Loop.
# Python Program to Print Multiplication Table print(" Multiplication Table ") for i in range(8, 10): for j in range(1, 11): print('{0} * {1} = {2}'.format(i, j, i*j)) print('==============')
OUTPUT
Python Program to display Multiplication Table Example 2
This Python program allows users to enter any integer value. Next, the print function in the For Loop prints the multiplication table from user-entered value to 10.
# Python Program to Print Multiplication Table num = int(input(" Please Enter any Positive Integer lessthan 10 : ")) print(" Multiplication Table ") for i in range(num, 10): for j in range(1, 11): print('{0} * {1} = {2}'.format(i, j, i*j)) print('==============')
OUTPUT
Python Program to display Multiplication Table using While loop
This Python multiplication table program is the same as above. But this time, we are using While Loop.
# Python Program to display Multiplication Table i = int(input(" Please Enter any Positive Integer lessthan 10 : ")) print(" Multiplication Table ") while(i <= 10): j = 1 while(j <= 10): print('{0} * {1} = {2}'.format(i, j, i*j)) j = j + 1 print('==============') i = i + 1
OUTPUT