In this simple python program, we need to print the multiplication table. It's a beginner-level python program.
To understand this example, you should have knowledge of the following Python programming topics:
In this beginner python program, we have to print the multiplication table of a number. The user has to enter the value of the number which the multiplication table is to print. It is a very simple python program as we need one for loop in python from 1 to 10 using the
The range function in python is used the
for loop to loop through a number of times, described in the prime number program. Using the
range() function, and the for loop starts from lower value to upper value - 1. So we have to use the upper value as 11 for printing the table up to 10.
Here in this python program, we have to accept the user input and convert it to an integer and save it to a num. Use a
for loop from the range, 1 to 11 and calculate and print the product of num and i.
STEP 1: Accept the number from the user. We use the input function in python language and convert the string to an integer using the int data type.
STEP 2: Use a
for loop to print the values using the range function from 1 to 10.
STEP 3: Print the multiplication table using the print statement.
num = int(input("Enter the number for printing the multiplication table : ")) for i in range(1,11): print(num,'x',i,'=',num*i)
Enter the number for printing the multiplication table : 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