1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
max2010maxim [7]
3 years ago
15

write a function copy(s, n) that takes as inputs a string s and an integer n, and that uses recursion to create and return a str

ing in which n copies of s have been concatenated together. python
Computers and Technology
1 answer:
Yuri [45]3 years ago
8 0

Answer:

Following are the method to the given question:

def copy(s, n):#defining a method copy that takes two parameters

   if n <= 0:#definig if to compare n value is less than equal to 0

       return ''#return space  

   else:#definig else block  

       return s + copy(s, n-1)#use recursive method that return value

print(copy("by",2))#calling method and print value

print(copy("ta",2))#calling method and print value

print(copy("good by ",2))#calling method and print value

Output:

byby

tata

good by good by

Explanation:

In this code, a method "copy" is declared that takes two parameters that are "s and n" inside the method a conditional statement is used which can be defined as follows.

In the if block is used "n" variable that checks n value which is less than equal to 0 if it is true it will return a space value.

In the else block it use the recursive method that returns a value which is a copy of s that is concatenated together.

You might be interested in
How can a user view the options for Junk E-mail?
alexdok [17]
B. by right clicking all messages in the junk email folder
8 0
3 years ago
Read 2 more answers
If Asa changes the text to bold, he has changed the style. True False
LiRa [457]
True because if you were to bold a text, you have presented that the following text is more important or exemplified. 
4 0
4 years ago
Read 2 more answers
What file holds the preferences and settings of the currently signed-in user??
VashaNatasha [74]
The answer to the question above is ntuser.dat. This is actually a registry file that contains the registry information of the user or account. According to Windows, this is known to be as the <span>"central hierarchical database" as this contains relevant information of the user such as profiles, and both of its hardware and software.</span>
3 0
3 years ago
When is the next Great Conjunction between Jupiter and Saturn?​
defon

Answer:

November 2040

Jupiter, which is the larger planet, takes 12 years to revolve around the sun, while Saturn takes 29 years. Every 20 years or so, they appear to observers on Earth to come closer to each other. The next Great Conjunction between the two planets – although not nearly as close together – is due in November 2040.

7 0
3 years ago
A user informs you that he or she never deletes any files he or she creates. How might this affect the operating system? It will
Juliette [100K]

Answer:

Depending on the amount of files there are, the operating system will run slower because these files take up space on the hard drive, slowing it down.

Explanation:

6 0
3 years ago
Other questions:
  • Hw to gain more knowledge ​
    6·1 answer
  • On the Internet, you can use a(n)______to look for information on any topic, such as books, movies, scholarly articles, news, an
    6·2 answers
  • Select the correct statement below. Group of answer choices
    6·2 answers
  • The ____ of an identifier refers to where in the program an identifier is accessible (visible).
    10·1 answer
  • The video game machines at your local arcade output coupons depending upon how well you play the game. You can redeem 10 coupons
    14·1 answer
  • Select the correct answer.
    6·1 answer
  • ما هي طرق اختبار الخرسانة <br>​
    14·1 answer
  • How do you select from the insertion point to the beginning of the current line?
    5·1 answer
  • The Windows Net use command is a quick way to discover any shared resources on a computer or server. True or False
    8·1 answer
  • In a DTP project, Fiona is looking for a way to make a page layout attractive to readers. Help Fiona pick the correct word to co
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!