Write A Python Program To Print Your Name 100 Times

 In this article you will learn a Python program to print your name a hundred times.  The name type is a string type so we have to print the string hundred times in order to print the name hundred times.

 Let's try to solve this using a Python program.

 

Write A Python Program To Print Your Name 100 Times

 

 

Write A Python Program To Print Your Name 100 Times

Take a string variable name,  ask the user to enter the name using the input function call and use the prints statement to print a user friendly message As shown below.

name = input("Please Enter Your Name : ")
print("Printing Your Name 100 times ...")



Use the for loop to iterate from 0 to 100, And during the iteration inside the for loop block print the name as shown below.

for _ in range(100):
   print(name)
 



Complete Python program using the for loop
=================================================

name = input("Please Enter Your Name : ")

print("Printing Your Name 100 times ...")

for _ in range(100):
   print(name)

 



The above Python program can also be rewritten using the while loop,  in case of while loop you have to initialize, check the condition and increment the index variable.

Complete Python program using while loop
================================================

name = input("Please Enter Your Name : ")

print("Printing Your Name 100 times ...")

index = 0
while index < 100:
   print(name)
   index += 1

 
 


The above Python program can also be modified  using the string multiplication operator,  just like arithmetic operators we can multiply the string multiple Times.

Python program using string multiply
============================================
name = input("Please Enter Your Name : ")

print("Printing Your Name 100 times ...")

print((name + "\n") * 100)





Output
=================
Please Enter Your Name : Code With TJ
Printing Your Name 100 times ...
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ
Code With TJ





Conclusion
===================
I have provided all the three methods to print a string using for loop using while loop and using the string multiplication.

commented down below if you have any queries related to above I can't program.

Post a Comment

0 Comments