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 manufacturer maker children kids The automobile manufacturer recommends car seats for children if the automobile doesn't already have one.

Answers

Answer 1

Answer:

In Python:

toreplace = input("Word and replacement: ")

sentence = input("Sentence: ")

wordsplit = toreplace.split(" ")

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

   sentence = sentence.replace(wordsplit[i], wordsplit[i+1])

print(sentence)

Explanation:

This gets each word and replacement from the user

toreplace = input("Word and replacement: ")

This gets the sentence from the user

sentence = input("Sentence: ")

This splits the word and replacement using split()

wordsplit = toreplace.split(" ")

This iterates through the split words

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

Each word is then replaced by its replacement in the sentence

   sentence = sentence.replace(wordsplit[i], wordsplit[i+1])

This prints the new sentence

print(sentence)


Related Questions


Open Office software is an example of what software

Answers

Answer:

Application software

Explanation:

OpenOffice.org (OOo), commonly known as OpenOffice, is a discontinued open-source office suite. ... OpenOffice included a word processor (Writer), a spreadsheet (Calc), a presentation application (Impress), a drawing application (Draw), a formula editor (Math), and a database management application (Base).

Write a Java program that uses a value-returning method to identify the prime numbers between 2 bounds (input from the user). The method should identify if a number is prime or not. Call it in a loop for all numbers between the 2 bounds and display only prime numbers. Check for errors in input.Note:A number is prime if it is larger than 1 and it is divisible only by 1 and itself(Note: 1 is NOT a prime number)Example:15 is NOT prime because 15 is divisible by 1, 3, 5, and 15; 19 is prime because 19 is divisible only by 1 and 19.

Answers

Answer:

Answered below.

Explanation:

public int[] primeNumbers(int lowBound, int highBound){

if(lowBound < 0 || highBound < 0 || lowBound >= highBound){

System.out.print("invalid inputs");

else if(highBound <= 1){

System.out.print("No prime numbers);

}

else{

int[] nums;

for(int I = lowBound; I <= highBound; I++){

if(isPrime (I)){

nums.add(I);

}

}

return nums;

}

Write a recursive method called sumTo that accepts an integer parameter n and returns a real number representing the sum of the first n reciprocals. In other words, sumTo(n) returns (1 1/2 1/3 1/4 ... 1/n). For example, sumTo(2) should return 1.5. The method should return 0.0 if it is passed the value 0 and throw an IllegalArgumentException if it is passed a value less than 0.

Answers

Answer:

Sorry mate I tried it was wrong

Explanation:

Sorry again

whats the most popular social networking in the philippines?

Answers

Y o u t u b e

It wont let me say the word above

Write a template that accepts an argument and returns its absolute value. The absolute entered by the user, then return the total. The argument sent into the function should be the number of values the function is to read. Test the template in a simple driver program that sends values of various types as arguments and displays the results.

Answers

Answer:

In python:

The template/function is as follows:

def absval(value):

   return abs(value)

Explanation:

This defines the function

def absval(value):

This returns the absolute value of the argument using the abs() function

   return abs(value)

To call the function from main, you may use:

print(absval(-4))

what is the economic and ideological causes of the American, the French,and the Chinese revolutions, and to see the larger historical contexts in which these events took place?​

Answers

Answer:

Explanation:The French who had direct contact with the Americans were able to successfully implement Enlightenment ideas into a new political system. The National Assembly in France even used the American Declaration of Independence as a model when drafting the Declaration of the Rights of Man and the Citizen in 1789.

arrange the following numbers from the highest to the lowest. ⅔,-7,0. no file or photo​

Answers

Answer:

2/3, 0, -7

Explanation:

What are the two functions in C that allow a programmer to randomly move the file cursor within a file stream, thus enabling random access. Please write down the names of the two functions and separate them by a comma only. As an example, assume the two functions are abc, and abe, you will write down your answer as abc,abe

Answers

Answer:

seekp(),tellp()

Explanation:

The two functions in c ++ that allow a programmer to randomly move the file cursor within a file stream are : seekp(),tellp()

The functions place cursor in file stream and also access the values

Write one line Linux command that performs the required action in each of the problems given below: (a) Find the difference in text between two text files File1.txt and File2.txt and save the result in a file named result.txt (b) Change the permissions of the file remote_driver.c such that the owner has the permissions to read, write and execute and anybody other than the owner can only read the file but cannot write or execute. (c) Search for the string ir_signal in the file /home/grad/remote_driver.c and print on the terminal the number of instances of the given string in the file /home/grad/remote_driver.c (d) Reboot the system after 5 minutes. (e) Display the list of processes currently being run by the user harvey. (f) Print 3 copies of a file named my_driver.c from a printer that has a name HPLaserJet4300. (g) Put the last 40 lines of the file driver_log.log into a new file final_fault.txt.

Answers

You have to add the integer

Programming a computer to win at chess
has been discussed since the
A. 1940's
B. 1950's
C. 1960's

Answers

I believe it was the 1960s but u should seach it up to double check

Answer:

B.

Explanation:

You are the IT administrator for a small corporate network. You have just changed the SATA hard disk in the workstation in the Executive Office. Now you need to edit the boot order to make it consistent with office standards. In this lab, your task is to configure the system to boot using devices in the following order: Internal HDD. CD/DVD/CD-RW drive. Onboard NIC. USB storage device. Disable booting from the diskette drive.

Answers

Answer:

this exercise doesn't make sense since I'm in IT

Explanation:

Other Questions
F(x)=0.5^x what is the domain and range Select the three numbers that show 225% as an equivalent fraction, decimal, or percent. (Hint- There are three correct answers: you must choose three answers.)A 225/50 B 225/100 C 9/4 D 0.225 E 2.25 helppppp will mark brainlest The sum of three times a number and six is nine 1st Amendment a) the right to a jury b) the right to reasonable punishment c) the right to protest d)the right to practice conversation e) the right to have an attorney What was the capital city of the Songhai Empire? In the early 20h century, a major goal ofRobert M. LaFollette and other Progressives was to1 start a civil rights movement for African Americans2 increase opportunities for citizen participationin government3 build support for imperialistic ventures inLatin America4 bring recognition to American artists and authors THIS IS THEANSWER, HAVEN'T GOTTEN A GRADE YET THO BUT IT'S RIGHTDescribe how globalization has changed culture over time.a) Identify ONE way in which popular and consumer culture became more global in the second half of the 20th century as a result of political and social changes.b) Identify ONE way in which entertainment shows the influence of globalized society.c) Explain ONE way in which consumer culture became globalized and went beyond national borders.A) One way in which popular and consumer culture became more global in the second half of the 20th century as a result of political and social changes was the fact that relations between countries were starting to get better, and in turn trade increased rapidly. Trade organizations such as the World Trade Organization and the European Union were being created, and global markets were starting to open up more and more as time went on. Popular and consumer culture was diffused through this process of increasing relations, as popular culture in other countries could be spread, and common consumer culture was easily spread through the increasingly prevalent global market that was being created. B) One way in which entertainment shows the influence of globalized society is the fact that entertainment in foreign countries often shows the effects of westernization. What I mean by this is that in other countries such as ones in Eastern Asia and the Western Pacific, often watch American or European media, and this influences their customs, and influences society as a whole. Entertainment itself is an effect of globalization, as many TV shows are made overseas and are marketed to foreign audiences, which wouldnt be able to happen without globalization. So, entertainment very effectively shows the influence of globalized society, as it shows how foreign businesses can now easily make it onto the most used household appliances. C) One way in which consumer culture became globalized and went beyond national border is the introduction of technology as a medium of shopping. Technology has heavily advanced the consumer experience, as you can shop from anywhere in the world, and get a product made anywhere in the world, and get it shipped right to you. Consumer culture has become globalized through this, and has easily gone beyond national borders, as there are little restrictions on e-commerce as compared to regular commerce, and the globalization of consumer culture has increased rapidly as a result. Julie and Kristen are partners in a local sporting good store. They needed $51,000 to start thebusiness. They invested in the ratio of 3:10 respectively. How much money did each invest?What percent is owned by Kristen? Evaluate the expression when a=-2 and x=6. \4x-a what happened to the Russian people during WWII Need help! much appreciated Help me plz. I need this done TODAY. Martha rolls a 6 sided number cube (number one through six) two times. What is the probability she will roll a 3 both times? 3. Explain how BOTH Sarah Koenig AND Adnan's prosecutors use expert witnesses as a form of persuasion. Use evidence to supportyour answer PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!!PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! PLSSS HELPPPP I WILLL GIVE YOU BRAINLIEST!!!!!! which is an example of observational learning? a) Taylor loves the taste of fast food because of the way he feels afterwardb) Tamra decides she won't repeat the mistakes she watched her older sister makec) Colleen notices her friend teasing the class lonerd) Jacques is tempted to experiment with drugs because he is having problems at home(I am thinking it is b. Correct me if I am wrong.) Which slaves were freed by the Emancipation Proclamation? A. Slaves born in the United States B. Slaves in territories in rebellion C. Slaves in the North D. Slaves in the border states The Fast Repair Shop charges a $25 fee plus $30 an hour for labor. Write the equation for the cost of the repair job, y, if the repair job took x hours. please help i will give brainilest How can adding electricity to possible solutions of a problem help generate better outcomes?i don't want to see any link If i do you will be reported