answer.
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
Ede4ka [16]
2 years ago
11

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.
Ex: If the input is:

automobile car children kids manufacturer maker The automobile manufacturer recommends car seats for children if the automobile doesn't already have one.

then the output is:
The car maker recommends car seats for kids if the car doesn't already have one.
You can assume the original words are unique.
Computers and Technology
1 answer:
marin [14]2 years ago
4 0

Answer:

Following are the program in the Python Programming Language

#set variable to input sentence to replace words

sen = input()

#split that sentence

sen = sen.split()

#set variable to input whole sentence

get = input()

#set the for loop to replace words

for i in range(0, len(sen), 2):

 #check condition when words of sen is in get

 if sen[i] in get:

   #then, replace words

   get = get.replace(sen[i], sen[i+1])

#print the whole string after replacing

print('\n',get)

Explanation:

<u>Following are the description of the program</u>.

  • Set a variable 'sen' that get a sentence for replacing the word.
  • Split that sentence by split() method and again store that sentence in the following variable.
  • Set a variable 'get' that gets the whole sentence from the user.
  • Set the for loop for replacing words then, set the if conditional statement that checks the condition that the variable 'sen' in the variable 'get' then replace the words.
  • Finally, print the whole sentence after the replacement.
You might be interested in
In an IPv4 datagram, the fragflag bit is 0, the value of HLEN is 5 (Its unit is word or 32-bits ), the value of total length is
Karolina [17]

Answer:

i aint sure

Explanation:

3 0
2 years ago
Jim has excellent oral and written communication skills. He enjoys public speaking and wants a job in which he will interact wit
lianna [129]
The best job for Jim would be public relations specialist.
7 0
2 years ago
Read 2 more answers
In which of the following stages of the development process is a team MOST likely to interview a potential user of an app?
Sedaia [141]

Answer:

Its c

Explanation:

5 0
2 years ago
When using preventative insecticides which holiday period should trigger an application?
Savatey [412]
Spring break around Easter I would believe
4 0
2 years ago
Read 2 more answers
Tyler wants to upgrade his very old operating system to the latest mac or microsoft operating system, but he cannot seem to inst
nordsb [41]
Every program has minimum system requirement, so at least His CPU is not good, or the amount of his RAM is too short to run the new version of OS.
6 0
2 years ago
Other questions:
  • Suppose that you have declared a numeric array named numbers, and two of its elements are numbers[1] and numbers[5]. you know th
    5·1 answer
  • You are given an array x of string elements along with an int variable n that contains the number of elements in the array. You
    11·1 answer
  • Design an algorithm for a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself."
    10·1 answer
  • Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the
    7·1 answer
  • (NumberFormatException)Write the bin2Dec(String binaryString) method to convert a binary string into a decimal number. Implement
    11·1 answer
  • Animated graphics that are displayed on the screen after a set of time when the computer is unattended.​
    8·1 answer
  • A Consider the following method definition. The method printAllCharacters is intended to print out every character in str, start
    11·1 answer
  • there is a structure called employee that holds information like employee code, name, date of joining. Write a program to create
    13·1 answer
  • B2B partners often connect to each other on the Internet through special __________ designed to facilitate information exchanges
    11·1 answer
  • You are an IT manager at Gigantic Life Insurance. You have a new desktop support person starting today whose experience is limit
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!