Westonci.ca makes finding answers easy, with a community of experts ready to provide you with the information you seek. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.

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.