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:
Deep Learning with Python - Francois Cholletf
Python Program to Check Leap Year
Python Program to Check If Two Strings are Anagram
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python object()
Python float()
Python Program to Find the Largest Among Three Numbers
Python Program to Print all Prime Numbers in an Interval
Python String format()
Python timestamp to datetime and vice-versa
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python hasattr()
Python int()
Python Program to Get the Full Path of the Current Working Directory
Python Numbers, Type Conversion and Mathematics
Python hash()
Python Program to Multiply Two Matrices
Python Set issuperset()
Python Program to Solve Quadratic Equation
Python Variables, Constants and Literals
Python repr()
Python Program to Find Numbers Divisible by Another Number
Python memoryview()
Python pass statement
Python Directory and Files Management
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Java Program to Implement the Schonhage-Strassen Algorithm for Multiplication of Two Numbers
Python Program to Slice Lists
Python delattr()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python Set copy()
Python Function Arguments