Write a program to Display the multiplication Table in Python
Code:
1 2 3 4 5 6 7 8 |
# To take input from the user num = int(input("Display multiplication table of? ")) # use for loop to iterate 10 times for i in range(1, 11): print(num,'x',i,'=',num*i) |
This Python program takes an input number from the user and displays the multiplication table of that number.
The program starts by asking the user to input a number, which is stored as an integer in the variable “num”.
Then, the program uses a for loop to iterate 10 times. On each iteration, it calculates the product of the input number and the current iteration number and prints the input number, the current iteration number, the symbol “x” and the product of the input number and the current iteration number to the output.
The output will be a list of strings, each one representing one line of the multiplication table of the input number, showing the input number, the current iteration number, the symbol “x” and the product of the input number and the current iteration number.
Take your time to comment on this article.