In this tutorial we shall learn about generating multiplication tables.For this program we are taking twoo integer values as input’s.One for which table to be printed and the other for limiting the table….For generating the table we need to consider a for loop.In “for” loop we use the range function to to limit the for loop.
n = int(input("\n Enter the number to find the table:")) limit = int(input("\n Enter limit upto which you need the table:")) i = 1 for i in range(1,(limit+1)) : print("\n\t\t" + str(n) + "*" + str(i)+"="+str((n*i)))
Explanation:In the above program,first we are asking the user to enter the table he wants and then the limit upto which he needs the table.While taking the input we are converting it to int because the default data type for input function is string.And then in the for loop we are using the range function and giving range as limit+1.
Output:
Nice script. Python is a breath of fresh air. Cool features to make concise code