Competitive Python Programming |
In this article, We will write a python program to print out the multiplication table of numbers.
If you are looking for a Python tutorial then it's here.
def printTable(num, nMultiple=10):
for multiple in range(1, nMultiple +1):
product = num*multiple
print(num,'*','%2d' % multiple, '=', '%4d'% product)
def main():
num = int(input('Enter the number: '))
printTable(num)
main()
The output of the above python code is:
Enter the number: 17
17 * 1 = 17
17 * 2 = 34
17 * 3 = 51
17 * 4 = 68
17 * 5 = 85
17 * 6 = 102
17 * 7 = 119
17 * 8 = 136
17 * 9 = 153
17 * 10 = 170
Comments
Post a Comment