This program displays the multiplication table of variable num (from 1 to 10).
To understand this example, you should have the knowledge of the following Python programming topics:
In the program below, we have used the for loop to display the multiplication table of 12.
Source Code
# Multiplication table (from 1 to 10) in Python
num = 12
# To take input from the user
# num = int(input("Display multiplication table of? "))
# Iterate 10 times from i = 1 to 10
for i in range(1, 11):
print(num, 'x', i, '=', num*i)
Output
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 have used the for loop along with the range() function to iterate 10 times. The arguments inside the range() function are (1, 11). Meaning, greater than or equal to 1 and less than 11.
We have displayed the multiplication table of variable num (which is 12 in our case). You can change the value of num in the above program to test for other values.
Related posts:
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python String rsplit()
Python help()
Python Set pop()
Python Program to Get the Last Element of the List
Python String count()
Python List remove()
Python Program to Count the Number of Occurrence of a Character in String
Python Dictionary values()
Python type()
Python Program to Compute all the Permutation of the String
Python Dictionary keys()
Python String encode()
Python Program to Add Two Numbers
Python Program to Differentiate Between del, remove, and pop on a List
Python Shallow Copy and Deep Copy
Python Program to Find ASCII Value of Character
Python Data Structures and Algorithms - Benjamin Baka
Python Program to Add Two Matrices
Python Global Keyword
Python Object Oriented Programming
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
Python Program to Append to a File
Python Program to Randomly Select an Element From the List
Python *args and **kwargs
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Program to Find Armstrong Number in an Interval
Python Program to Trim Whitespace From a String
Python print()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Program to Copy a File
Python Program to Solve Quadratic Equation