Ask Question
7 November, 19:19

Write code that prompts the user for a phrase and a number of times to repeat it, then prints the phrase that many times. Here is an example dialogue with the user: What is your phrase? His name is Robert Paulson How many times should I repeat it? 3 His name is Robert Paulson His name is Robert Paulson His name is Robert Paulson

+4
Answers (1)
  1. 7 November, 19:23
    0
    phrase=str (input ("Waht is your phrase?/n")) #prompting phrase.

    rep=int (input ("How many times should I repeat it?")) #prompting repetitions integer.

    print (phrase*rep) #printing the phrase.

    Output:-

    What is your phrase?

    My name is Mark.

    How many times should I repeat it?

    4

    My name is Mark. My name is Mark. My name is Mark. My name is Mark.

    Explanation:

    I have coded in python language. First I am prompting the phrase form the user in the variable phrase, then I am prompting the integer for repetitions in the variable name rep. Then printing the phrase for rep number of times.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write code that prompts the user for a phrase and a number of times to repeat it, then prints the phrase that many times. Here is an ...” in 📗 Social Studies if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers