You are currently viewing Python Program to Print Table of 2 and others

Python Program to Print Table of 2 and others

In the previous article, we have seen how we can concatenate two strings and how we can add two numeric numbers. In this article, we will see how we can print a table of 2 first and then how you can use the same logic to print other tables. To print the table we will use the Range function of Python.

Let us see how we can print the table of 2.

Code:

for i in range(1,11):
c=2*i
print(c)

Output: 

2
4
6
8
10
12
14
16
18
20

Above program has a fixed table value. Now let us take input from the user and print table of that number. To take input from user we will use input() function.

Code:

tableNumber=int(input('Enter table which you want to print'))  //Lets say user has ented 4

for i in range(1,11):

c=tableNumber*i

print(tableNumber,'*',i,"=",c)

 

Output :

4
8
16
20
24
28
32
36
40

That’s it Folks on this topic. Let us know your comments on this article in the comment box below. Kindly like our Facebook page, follows us on Twitter and subscribe to our YouTube channel for latest updates.

Leave a Reply