Python program to generate Multiplication table

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:
tables

Download the source code

Advertisement

About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my PhD in Computer Science.
This entry was posted in Python and tagged , , , , , , , , , , . Bookmark the permalink.

1 Response to Python program to generate Multiplication table

  1. joseph says:

    Nice script. Python is a breath of fresh air. Cool features to make concise code

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s