write a python program to print table of 5

Hi Guys, welcome to my blog in this article you will learn about how to Write A Python Program To Print Table Of 5

 

Title : 

Write A Python Program To Print Table Of 5 

 

Write A Python Program To Print Table Of 5

 

Description : 

Hi guys, in this article you will learn The Python program to print the multiplication table of the number 5. Let's try to solve this using both for loop and while loop. let's look into the for loop program, take a number and initialize it to 5. Now using the print function call print a user friendly message as shown below. Now using the for iterate from 1 to 11 and give the index value use the print function to multiply numbers with the index value and print the multiplication table.


    

number = 5
print(f"Multiplication Table of : {number}")
for index in range(1, 11):
   print(f"{number} x {index} = {number * index}")


    


Now let's try to use the while loop and print the multiplication table of 5. take a variable number and initialise it to 5, print a user friendly message. Take the variables index and limit initialize it to one and 11 respectively. use the while loop to iterate until index becomes the limit to get the range between 1 to 10 and multiply it will the number to print the multiplication table


    

number = 5
print(f"Multiplication Table of : {number}")
index = 1
limit = 11
while index < limit:
   print(f"{number} x {index} = {number * index}")
   index += 1



    




Complete Python Code : 


    

Using For Loop
============================
number = 5
print(f"Multiplication Table of : {number}")
for index in range(1, 11):
   print(f"{number} x {index} = {number * index}")


Using While Loop
============================
number = 5
print(f"Multiplication Table of : {number}")
index = 1
limit = 11
while index < limit:
   print(f"{number} x {index} = {number * index}")
   index += 1

    

 

 

Output : 


    
Multiplication Table of : 5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50




    

 

Output : 


    

Refer above


    



Conclusion :

The above Python programs Uses the looping method to bring the multiplication table. The first program uses the for loop to get the range from 1 to 10 and multiplies it with the number 5 to print the multiplication table. The second program uses the while loop to get the range from 1 to 10 and multiplies it with the number 5 to bring the multiplication table Comment it down below if you have any query is regarding the above Python program Subscribe to my YouTube channel, so you don't miss out new content 

https://www.youtube.com/channel/UCUooZAqgfE4ngJ0oXsj3-MA

 

Post a Comment

0 Comments