Python Program to Print a Multiplication Table using While Loop
This example shows, how to print the multiplication table using while loop in python.
Steps
- Get the input from user (t) for which the multiplication table is to be generated.
- Get the input from user (n) for the multiplication table.
- The loop starts at i = 1 and continues until i exceeds n.
- In each iteration of the loop, the current multiplication result (i * t) is calculated and printed.
- The counter i is incremented after each iteration to move to the next step of the multiplication table.
Example :
Example.py
i=1 t=int(input("Enter table no: ")) n=int(input("Enter limit: ")) while(i<=n): print(t,"*",i,"=",i*t) i+=1
Output
Enter table no: 10 Enter limit: 10 10 * 1 = 10 10 * 2 = 20 10 * 3 = 30 10 * 4 = 40 10 * 5 = 50 10 * 6 = 60 10 * 7 = 70 10 * 8 = 80 10 * 9 = 90 10 * 10 = 100