English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This program displays the multiplication table of the variable num (from1to10)。
To understand this example, you should understand the followingPython programmingTopic:
In the following program, we use for loop to display12multiplication table.
# Multiplication table in Python (from1to10) num = 12 # Get input from the user # num = int(input("Show multiplication table? ")) # iteration10times, from i = 1to10 for i in range(1, 11) print(num, 'x', i, '=', num*i)
Output result
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
Here, we use for loop andrange() functionto iterate10times. The parameter inside the range() function is (1,11)。Indicates greater than or equal to1and less than11。
We have displayed the multiplication table of the variable num (in this example,12)。You can change the values that you can modify in the above program to test other values.