Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Explore a wealth of knowledge from professionals across different disciplines on our comprehensive platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.

Programming Exercise:
1- Write a program that asks the user to enter a
word and then prints that word 25 times (each on
separate lines)


Sagot :

Method 1:

word = input("> ")

for _ in range(25):

   print(word)

Assigning the variable "word" to the function input() (Which retreves what the user types). Then using a for loop which repeats 25 times. And each time print the word. The print() function automatically creates a new line.

Method 2:

print(f"{input('> ')}\n"*25)

This code does the exact same thing as previously but only calls the print() function once and instead creates a string which is 25 lines long and has the users' input on each line. It's cool to write it on a single line, however, not very pedagogcall and pretty messy.

Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.