Display Multiplication table in Python
Read an integer using input() function.
print(f"Multiplication table of {number} is")
Use for loop to iterate multiplication for 10 times.
print(number,"*",i,"=",number*i).
As a result we get the output as a multiplication table of number.
Input:
enter any integer : 5
Output :
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
Program to display multiplication table in python.
#Multiplication table in python
number=int(input("enter any integer "))
print(f"Multiplication table of {number} is")
for i in range(1,11):
print(f'{number}*{i}={number*i}')
#---------without format specifiers---------#
for i in range(1,11):
print(number,"*",i,"=",number*i)
Output :
enter any integer 5
Multiplication table of 5 is
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
Comments
Post a Comment
Type Your Comments !
Please do not enter any spam link in the comment box.