Find the table of the number in python by R4R Team

program to find the table of given number in python -

n=int(input("Enter any number to find the tablen"))

#by for loop
print("With the help of for loop")
for i in range(1,11):
print(str(n)+"*"+str(i)+"="+str(n*i))

#by while loop
print("With the help of while loop")
i=1
while(i<11):
print(str(n)+"*"+str(i)+"="+str(n*i))
i=i+1

#by recursion
print("With the help of recursion")
def table(n,i):
if i==11:
return
print(str(n)+"*"+str(i)+"="+str(n*i))
table(n,i+1)
table(n,1)


output -

Enter any number to find the table
3
With the help of for loop
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
3*6=18
3*7=21
3*8=24
3*9=27
3*10=30
With the help of while loop
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
3*6=18
3*7=21
3*8=24
3*9=27
3*10=30
With the help of recursion
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
3*6=18
3*7=21
3*8=24
3*9=27
3*10=30



Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!