Table of Contents
In this article, we will discuss the concept of Program to Multiplication table in given range using Python
In this program, we are going to learn how to generate a multiplication table using several ways in Python language.
This is done using for loop , while loop and function in Python language
In this program, we will display multiplication table of a number in given range using for loop in Python language
Program 1
#python program to print mutipication table #of a number in given range num=int(input("Enter the number: ")) ran=int(input("Enter the range: ")) print("Multiplication table of %d "%num) for i in range(1,ran+1): print(num,"x",i,"=",num*i)
When the above code is executed, it produces the following result
Enter the number: 16 Enter the range: 12 Multiplication table of 16 16 x 1 = 16 16 x 2 = 32 16 x 3 = 48 16 x 4 = 64 16 x 5 = 80 16 x 6 = 96 16 x 7 = 112 16 x 8 = 128 16 x 9 = 144 16 x 10 = 160 16 x 11 = 176 16 x 12 = 192
In this program, we will display multiplication table of a number in given range using while loop in Python language
Program 2
#python program to print mutipication table #of a number in given range num=int(input("Enter the number: ")) ran=int(input("Enter the range: ")) print("Multiplication table of %d "%num) i=1; while(i<=ran): print(num,"x",i,"=",num*i) i=i+1
When the above code is executed, it produces the following result
Enter the number: 11 Enter the range: 16 Multiplication table of 11 11 x 1 = 11 11 x 2 = 22 11 x 3 = 33 11 x 4 = 44 11 x 5 = 55 11 x 6 = 66 11 x 7 = 77 11 x 8 = 88 11 x 9 = 99 11 x 10 = 110 11 x 11 = 121 11 x 12 = 132 11 x 13 = 143 11 x 14 = 154 11 x 15 = 165 11 x 16 = 176
In this program, we will display multiplication table of a number in given range using function in Python language
Program 3
#python program to print mutipication table #of a number in given range num=int(input("Enter the number: ")) ran=int(input("Enter the range: ")) print("Multiplication table of %d "%num) def mul_Table(num):#function definition for i in range(1,ran+1): print(num,"x",i,"=",num*i) mul_Table(num)#function call
When the above code is executed, it produces the following result
Enter the number: 9 Enter the range: 16 Multiplication table of 9 9 x 1 = 9 9 x 2 = 18 9 x 3 = 27 9 x 4 = 36 9 x 5 = 45 9 x 6 = 54 9 x 7 = 63 9 x 8 = 72 9 x 9 = 81 9 x 10 = 90 9 x 11 = 99 9 x 12 = 108 9 x 13 = 117 9 x 14 = 126 9 x 15 = 135 9 x 16 = 144
Suggested post
Similar post
Code to Display multiplication table in Java
Code to Display multiplication table in C
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.