subject

Write a python program that will translate words into "pirate speak." start by looking at the following file: translation. txt you will see that the file contains a series of translations from boring old english into pirate speak. the english string is separated from the pirate string by a colon, and each pair appears on a separate line. using this information, your program should ask the user to enter a line, and then it should translate the line into pirate speak. part of the translation involves randomly adding "are" to the end of some sentences. this should continue until the user enters "quit". the following is a sample interaction: art! welcome to the pirate translator! enter a line excuse me miss where is the restroom are comely wench what be the' head enter a line pardon me stranger but the officer is in the pub vast scurvy dog but the' foul braggart be in the' skull & scuppers, arr. enter a line: this is crazy this be crazy, arr. enter a line : quit follow these steps to create the translator program. be sure to use methods and comment as you write the code! test each part as you go. start by parsing the lines of the file into a dictionary structure. each line should be read in and split based on the colon character. before adding the phrases to the dictionary, be sure to remove the new line character from the end using the strip() command. create a loop that asks the user for a string until they enter "quit". in the string, replace each key in the dictionary with its pirate equivalent. add ", arr." to the end of the line with 30% probability. print the line. there is a subtle bug in the algorithm. when replacing a string with another, all instances of that string are replaced, even if it is in the middle of a word. for example, "is" gets replaced with "be", but "this is crazy" should not be translated into "the be crazy". fix this bug in the program.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 03:10
Fill in the following program so that it will correctly calculate the price of the orange juice the user is buying based on the buy one get one sale.#include //main functionint main() { int cartons; float price, total; //prompt user for input information printf("what is the cost of one container of oj in dollars? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & price); printf("how many containers are you buying? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & cartons); if ( [ select ] ["cartons / 2", "cartons % 1", "cartons % 2", "cartons % price", "cartons / price", "cartons / total"] [ select ] ["=", "==", "! =", "< =", "> =", "< "] 0) total = [ select ] ["price * cartons", "cartons * price / 2 + price", "(cartons / 2) * price", "cartons / (2.0 * price)", "(cartons / 2.0) * price + price", "((cartons / 2) * price) + price"] ; else total = ((cartons / 2) * price) + price; printf("the total cost is $%.2f.\n", total); return 0; }
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Uget brainliest if accurate mary has been given the responsibility of hiring a person for the position of a software testing officer. which management function would mary achieve this responsibility?
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
Answers: 1
You know the right answer?
Write a python program that will translate words into "pirate speak." start by looking at the follow...
Questions