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
The rock cycle _____.
creativ13 [48]
The best and most correct answer among the choices provided by the question is the second choice. The rock cycle <span>changes and recycles Earth's rocks. </span>I hope my answer has come to your help. God bless and have a nice day ahead!
8 0
3 years ago
The _____ row is typically the first row in a table.<br><br> banded<br> total<br> header<br> odd
rusak2 [61]

the first row of the table is know as the table header.

8 0
3 years ago
Read 2 more answers
If you wanted to detect x-rays coming from the sun,where would you place the detector? Why?
Temka [501]
You would place it in orbit around Earth, as most X-rays are absorbed by the atmosphere, so you would want the detector outside of the atmosphere to accurately detect the X-rays.
5 0
3 years ago
NumA=2<br> for count range (5,8)<br> numA=numA+count <br> print(numA)
love history [14]

Answer:

for count in range (5,8): numA=numA+count print(numA)

Explanation:

7 0
3 years ago
at the bank there is 4 lines with 7 costumers and there are five customers left over. how many customers are there​
mrs_skeptik [129]
Answer: 33
7 times 4 is 28 add the left over 5 makes 33 people
4 0
3 years ago
Other questions:
  • Suppose two hosts, A and B, are separated by 7,500 kilometers and are connected by a direct link of R = 10 Mbps. Suppose the pro
    7·1 answer
  • How is a network address of 192.168.6.0 and a subnet mask of 255.255.254.0 written in cidr?
    12·1 answer
  • / List the seven basic internal components found in a computer tower.
    5·2 answers
  • 1. Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address
    7·1 answer
  • Play among us with me
    12·2 answers
  • Which of the following is not given to a client computer when it is first installed on a TCP/IP network so that it has the appro
    9·1 answer
  • Which elements are in the Sort dialog box? Check all that apply.
    9·1 answer
  • How are logical operators used?
    14·1 answer
  • Which of the following is not a common input device?
    6·1 answer
  • A ____ is someone who develops programs and apps or writes the instructions that direct the computer or mobile device to process
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!