{"id":6829,"date":"2023-10-31T17:17:28","date_gmt":"2023-10-31T11:47:28","guid":{"rendered":"https:\/\/python-programs.com\/?p=6829"},"modified":"2023-11-10T12:09:49","modified_gmt":"2023-11-10T06:39:49","slug":"python-program-to-display-the-multiplication-table","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-display-the-multiplication-table\/","title":{"rendered":"Python Program to Display the Multiplication Table"},"content":{"rendered":"
Given a number the task is to print the multiplication table of the given number from 1 to 10.<\/p>\n
Prerequisite:<\/strong><\/p>\n 1)For Loop in python<\/a><\/strong><\/p>\n 2)While Loop in python<\/a><\/strong><\/p>\n Explore more instances related to python concepts from Python Programming Examples<\/a> Guide and get promoted from beginner to professional programmer level in Python Programming Language.<\/p>\n Examples:<\/strong><\/p>\n Example 1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example 2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to print the multiplication table:<\/p>\n Approach:<\/strong><\/p>\n To iterate 10 times, we used the for loop in combination with the range() function. The range() function’s arguments are as follows: (1, 11). That is, greater than or equal to 1\u00a0and less than 11.<\/p>\n We’ve shown the variable num multiplication table (which is 8 in our case). To evaluate for other values, adjust the value of num in the above\u00a0program.<\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Related Programs<\/strong>:<\/p>\n Given a number the task is to print the multiplication table of the given number from 1 to 10. Prerequisite: 1)For Loop in python 2)While Loop in python Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language. Examples: Example …<\/p>\nnumber=8<\/pre>\n
8 * 1 = 8\r\n8 * 2 = 16\r\n8 * 3 = 24\r\n8 * 4 = 32\r\n8 * 5 = 40\r\n8 * 6 = 48\r\n8 * 7 = 56\r\n8 * 8 = 64\r\n8 * 9 = 72\r\n8 * 10 = 80<\/pre>\n
number=34<\/pre>\n
34 * 1 = 34\r\n34 * 2 = 68\r\n34 * 3 = 102\r\n34 * 4 = 136\r\n34 * 5 = 170\r\n34 * 6 = 204\r\n34 * 7 = 238\r\n34 * 8 = 272\r\n34 * 9 = 306\r\n34 * 10 = 340<\/pre>\n
Program to Print the Multiplication Table<\/h2>\n
\n
Method #1:Using for loop<\/h3>\n
# given number\r\nnumber = 8\r\n# using for loop with range\r\nfor i in range(1, 11):\r\n print(number, \"*\", i, \"=\", number*i)\r\n<\/pre>\n
8 * 1 = 8\r\n8 * 2 = 16\r\n8 * 3 = 24\r\n8 * 4 = 32\r\n8 * 5 = 40\r\n8 * 6 = 48\r\n8 * 7 = 56\r\n8 * 8 = 64\r\n8 * 9 = 72\r\n8 * 10 = 80<\/pre>\n
Method #2:Using While loop<\/h3>\n
\n
# given number\r\nnumber = 8\r\n# initializing a variable say multiplication factor to 1\r\nmultiplicationfactor = 1\r\n# loop till multiplicationfactor is less than or equal to 10\r\nwhile(multiplicationfactor <= 10):\r\n print(number, \"*\", multiplicationfactor, \"=\", number*multiplicationfactor)\r\n # increment the multiplicationfactor by 1\r\n multiplicationfactor = multiplicationfactor+1\r\n<\/pre>\n
8 * 1 = 8\r\n8 * 2 = 16\r\n8 * 3 = 24\r\n8 * 4 = 32\r\n8 * 5 = 40\r\n8 * 6 = 48\r\n8 * 7 = 56\r\n8 * 8 = 64\r\n8 * 9 = 72\r\n8 * 10 = 80<\/pre>\n
\n