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
Colt1911 [192]
4 years ago
12

Write a program that replaces words in a sentence. The input begins with word replacement pairs (original and replacement). The

next line of input is the sentence where any word on the original list is replaced.

Computers and Technology
2 answers:
Aloiza [94]4 years ago
7 0

Answer:

sentence=input("Enter a sentence:")

lis= sentence.split();

print(lis)

word=input("Enter the word to replace:")

word1=input("Enter the word to be replaced:")

i=0

for i in range(0, len(lis)):

   if lis[i]==word:

       lis[i]=word1

       i+=1

   else:

       i+=1

       continue

print("Sentence after replacement is")

print(*lis)

Explanation:

The code is as above. We here are splitting the sentence and storing in a list. And then we are replacing the word, and finally printing the sentence with replaced word.

alukav5142 [94]4 years ago
6 0

Answer:

This program is written in C++ language using Dev C++. The explanation of code is given below:

Explanation:

#include<iostream>

#include <bits/stdc++.h>

using namespace std;

 

int main()

{

   string str;// user enter sentence

   string find;//find word in sentence

   string replace;//replace word in sentence

   cout<<"Enter Sentence\n";

   getline(cin, str);//user enter sentence

   cout<<"\n Now enter key to find in sentence\n";

   getline(cin,find);//user enter "word" to find in sentence

   int findSize=(int)find.size();

   cout<<"\nNow enter a replacing word\n";

   getline(cin,replace);//user enter "word" to replace in sentence

cout << "\nOriginal text: " << str;//show original sentence

       for (int j = 0; j < (int)str.size(); j++) {//loop  

           string key = str.substr(j, findSize), repl; //search in sentence

           if (key == find) {//if find

               repl = replace;//replace

               for (int k = 0; k < findSize+2; k++) {//append

                   str[j+k] = repl[k];// new sentence

               }

           }

       }

      cout <<"\nNew text: " << str << endl;

   

   return 0;

}

You might be interested in
What is the best programming language
pashok25 [27]

Answer:

Ther are 8 best programming language :

• Javascript

• Swift

• Scala

• Go

• Python

• Elm

• Ruby

• C#

4 0
3 years ago
What is one reason why private loans are less favorable than federal loans?
Lilit [14]
The answer is higher interest rate
6 0
4 years ago
Read 2 more answers
Describe server processing of a post request. in the case of cgi processing, how does the server pass information to a cgi progr
Aneli [31]

CGI is the part of the Web server that can communicate with other programs running on the server.

<h3>What is The Common Gateway Interface? </h3>

The Common Gateway Interface (CGI) provides middleware between WWW servers and external databases and information sources. The World Wide Web Consortium (W3C) defined the Common Gateway Interface (CGI) and also defined how a program interacts with an HTTP (Hyper Text Transfer Protocol) server.

The body of the message is sent to the CGI program by the server through the stanard input pipe. Using the value of content_length, which indicates the length of the body, the CGI program can parse the input and obtain the values of the data entered by the user.

See more about CGI at brainly.com/question/12972374

#SPJ1

8 0
1 year ago
In dhcp, what address is reserved for use by clients that are not yet configured with an ip address?
kicyunya [14]
The answer is : 0.0.0.0   In DHCP, 0.0.0.0 is reserved for use by clients that are not yet configured with an IP address.  <span>The IP address 0.0.0.0 indicates different uses at different places. Usually, it’s a non-routable meta address that’s not bound to any particular remote address. Dealing with servers, it means all IPv4 addresses in the local machine.</span>
5 0
3 years ago
What is the name of the device protected by a digital certificate?
andrew-mc [135]

Answer:

Security – Simply put, digital certificates are the most practical option to securing your corporate data online. Digital certificates encrypt your internal and external communications to avoid outsiders and phishers from stealing sensitive information.

Explanation:

6 0
3 years ago
Other questions:
  • Suppose that the code below is the body of some loop. Given variables x and y write some code that reads a value into the variab
    5·1 answer
  • Write a Python function isPrime(number) that determines if the integer argument number is prime or not. The function will return
    7·1 answer
  • What is RAD? List an advantage and a disadvantage of using RAD.
    11·1 answer
  • Jasper and Samantha are in a robotics competition. The guidelines state that the robots should be able to move a 10-gram weight
    9·1 answer
  • Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guz
    9·1 answer
  • What is Product Owner work that a Product Owner might delegate?
    10·1 answer
  • Windows displays a(n)
    11·1 answer
  • An array A[0..n - 2] contains `n-1` integers from 1 to `n` in increasing order. (Thus one integer in this range is missing.) Des
    11·1 answer
  • B. What significant values have you learned while learning the tools and utensils?
    8·1 answer
  • What made the digital distribution of both data and visualization more accessible to a broader audience?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!