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
larisa [96]
3 years ago
11

#Write a function called "replace_all" that accepts three #arguments: # # - target_string, a string in which to search. # - find

_string, a string to search for. # - replace_string, a string to use to replace every instance # of the value of find. # #The arguments will be provided in this order. Your function #should mimic the behavior of "replace", but you cannot use #that function in your implementation. Instead, you should #find the result using a combination of split() and join(), #or some other method. # #Hint: This exercise can be complicated, but it can also #be done in a single short line of code! Think carefully about #the methods we've covered. #Write your function here!

Computers and Technology
1 answer:
gulaghasi [49]3 years ago
7 0

Answer:

Here is the function replace_all:

def replace_all(target_string,find_string,replace_string):

   result_string = replace_string.join(target_string.split(find_string))  

   return result_string

#if you want to see the working of this function then you can call this function using the following statements:

target_string = "In case I don't see ya, good afternoon, good evening, and good night!"

find_string = "good"

replace_string = "bad"

print(replace_all(target_string, find_string, replace_string)

Explanation:

The above program has a function called replace_all that accepts three arguments i.e target_string, a string in which to search ,find_string, a string to search for and replace_string, a string to use to replace every instance of the value of find_string. The function has the following statement:

replace_string.join(target_string.split(find_string))  

split() method in the above statement is splits or breaks the target_string in to a list of strings based on find_string. Here find_string is passed to split() method as a parameter which works as a separator. For example above:

target_string = In case I don't see ya, good afternoon, good evening, and good night!

find_string = good

After using target_string.split(find_string) we get:

["In case I don't see ya, ", ' afternoon, ', ' evening, and ', ' night']

Next join() method is used to return a string concatenated with the elements of target_string.split(find_string). Here join takes the list ["In case I don't see ya, ", ' afternoon, ', ' evening, and ', ' night'] as parameter and joins elements of this list by 'bad'.

replace_string = bad

After using replace_string.join(target_string.split(find_string))  we get:

In case I don't see ya, bad afternoon, bad evening, and bad night!  

The program and output is attached as a screenshot.

You might be interested in
Type size in a textbook may be used to indicate the relative importance of ideas.
Alborosie
Yes true 

hey is this one of your questions on a science packet if so it is called explore ring Earth's surface because I have the same packet with the same question on it
3 0
2 years ago
Read 2 more answers
Three periods after a menu item (...) mean that clicking that command will open
erastovalidia [21]

I think its B.) A dialog box


7 0
2 years ago
Read 2 more answers
How would you use SQL to change a table's structure? What general types of changes are possible? Which commands are used to impl
xz_007 [3.2K]

The SQL is used to change a table's structure by:

The use of the SQL ALTER TABLE command.

<h3>How is it done?</h3>

The SQL ALTER TABLE command is known to  be that which is often used to alter the structure of an existing table.

It is known to help one to be able to add or delete columns, make or destroy indexes, alter the kinds of existing columns, rename columns or the table itself.

Note that  It can also be used to alter the comment for any kind of table and type of the table therein.

Learn more about SQL from

brainly.com/question/25694408

#SPJ1

4 0
2 years ago
Write a SELECT statement that returns these three columns: vendor_nameThe vendor_name column from the Vendors table default_acco
Sati [7]

Explanation:

"Select vendor_name as Vendor_Name,

default_account_number as Default_Account_No ,

account_description as Account_Description

From Vendors v, General_Ledger_Accounts ledger

where (add the join condition here)

Order by account_description, vendor_name"

Note: In the above statement, include the alias name appropriately and then execute the query

The "select statement" should contain the list of columns to be displayed

"From statement" should contain the name of the table from which data needs to be fetched.

"Where clause" defines the relationship as well the condition that needs to be executed

"Order by clause" defines the sorting mechanism with the relevant field

5 0
3 years ago
Define storage device with two examples? ​
Vlad [161]

Answer:

Hehe!

Explanation:

Storage Device is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers. The central processing unit of a computer is what manipulates data by performing computations.

Examples: Hard disk and Floopy Disk.

7 0
2 years ago
Read 2 more answers
Other questions:
  • Alejandra is using a flash drive that a friend gave to her to copy some financial records from the company database so she can c
    12·1 answer
  • 6. Why did he choose to install the window not totally plumb?
    13·1 answer
  • In theory, a(n) _____ can be an independent centralized database management system with proper interfaces to support remote acce
    15·1 answer
  • There are two main advantages to using multiple threads in a process: 1) Less work involved in creating a new thread rather than
    7·1 answer
  • How to simplify???? 2(-3x^2+6x+1)-2(4x^2-3x+1)<br><br>​
    7·1 answer
  • Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cre
    11·1 answer
  • Both UDP and TCP use port numbers to identify the destination entity when delivering a message. Give at least one reason for why
    12·1 answer
  • What is the difference between business strategies and business models?
    9·1 answer
  • Which of the following statements describes the general idea of an assistive media​
    7·1 answer
  • While conducting routine maintenance, you discover a network server that needs to
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!