VALUES

Multiplication Table using Python program

              Hello, In this blog we see the Python code to print multiplication table. In this program user give the input and depends on that integer number the multiplication table will displayed.

Code:

num = int(input(“Display multiplication table of? “))
for i in range(1, 11):
   print(num, ‘x’, i, ‘=’, num*i)

In the above code we use the range function. So easily we compact the code as compare to c, c++, java. In last print line all the operations are taken in one line and the output is displayed to the user.
Output:


Display multiplication table of? 12
12 x 1 = 12
12 x 2 = 24
12 x 3 = 36
12 x 4 = 48
12 x 5 = 60
12 x 6 = 72
12 x 7 = 84
12 x 8 = 96
12 x 9 = 108
12 x 10 = 120

Related Articles

Back to top button