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 property()
Python String rindex()
Python Keywords and Identifiers
Python ord()
Python max()
Python filter()
Python String startswith()
Python while Loop
Python Program to Access Index of a List Using for Loop
Python Program to Find All File with .txt Extension Present Inside a Directory
Python strftime()
Python Program to Get the File Name From the File Path
Python Input, Output and Import
Python Program to Illustrate Different Set Operations
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python hash()
Python String format_map()
Python RegEx
Python Set symmetric_difference()
Python Program to Parse a String to a Float or Int
Introduction to Scientific Programming with Python - Joakim Sundnes
Python zip()
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Shuffle Deck of Cards
Python Set difference_update()
Python len()
Python datetime
Python Program to Extract Extension From the File Name
Python Variables, Constants and Literals
Python Program to Multiply Two Matrices
Python bin()
Python str()