Reverse Multiplication Table Using For loop in Python
A multiplication table of any number can be printed using the For loop in Python. We can also print the multiplication table in reverse order using a for loop in Python. In this article, we will see how we can print the multiplication table in reverse order using a for loop in Python.
Example:
Input: TableNumber = 2
Output:
Printing Multiplication Table of 2 in reverse order
10 * 2 = 20
9 * 2 = 18
8 * 2 = 16
7 * 2 = 14
6 * 2 = 12
5 * 2 = 10
4 * 2 = 8
3 * 2 = 6
2 * 2 = 4
1 * 2 = 2
Reverse Multiplication Table Using For loop in Python
Below are some of the ways by which we can print the multiplication table in reverse order using for loop in Python:
- By taking user input
- By predefined multiplier
Reverse Multiplication Table by Getting User-Defined Multiplier
In this example, the code first prompts the user for a number, then prints its multiplication table in reverse order, starting from 10 down to 1.
print("Enter the number of multiplication table to print:")
# Getting the number of multiplication table from user
tableNumber = int(input())
print("Printing Multiplication Table of", tableNumber, "in Reverse Order")
# Using For loop to print Multiplication table from number 10 to 1 of user input number
for num in range(10, 0, -1):
print(num, "*", tableNumber, " =", (num * tableNumber))
Output:
Enter the Number of Multiplication Table to Print:
5
Printing Multiplication Table of 5 in Reverse Order:
10 * 5 = 50
9 * 5 = 45
8 * 5 = 40
7 * 5 = 35
6 * 5 = 30
5 * 5 = 25
4 * 5 = 20
3 * 5 = 15
2 * 5 = 10
1 * 5 = 5
Reverse Multiplication Table of Pre-defined Multiplier Number
In this example, the code generates the multiplication table of 2 in reverse order. It starts by setting the multiplier to 2, then uses a for loop to iterate through numbers from 10 down to 1. For each number, it multiplies it by the multiplier and prints the result, creating a descending table of multiplication facts for 2.
multiplier = 2
# for loop running from 10 to 1 in reverse
for num in range(10, 0, -1):
print(num, "*", multiplier, "=", (num*multiplier))
Output:
10 * 2 = 20
9 * 2 = 18
8 * 2 = 16
7 * 2 = 14
6 * 2 = 12
5 * 2 = 10
4 * 2 = 8
3 * 2 = 6
2 * 2 = 4
1 * 2 = 2