Courses‎ > ‎Intro to CS - Full Year‎ > ‎Spring‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

Work 19: 3/22

posted Mar 22, 2019, 7:18 AM by JonAlf Dyrland-Weaver
Write a program that will translate a string into pirate speak using the following rules:
  • Exclamation point at the end of each sentence.
  • you --> ye
  • your -->yer
  • the --> t'
  • words that end with ing --> in'
  • I, my, mine --> me
  • am, is, are, 're --> be
  • myself --> meself
  • for -->fer
  • Arrr! after every other sentence
A few notes:
  • There is a built in python string replace function that you should use instead of the one we have been working on. It works like this:
    • s.replace(<KEY>, <REPLACEMENT>)
      • Returns a copy of s where every instance of KEY is replaced with REPLACEMENT
      • example: 
        •  s = 'I do not like green eggs and ham, I do not like them Sam I am'
        • s.replace('not', 'really') ==> 'I do really love green eggs and ham, I do really like them Sam I am'
  • Below is some example text, but it does not check every case, you should create test cases that check all the potential replacements.
Example:
Sorry to disappoint you and all that, 
but the greatest wizard in the world is 
Albus Dumbledore. Everyone says so. Even 
when you were strong, you didn't dare try 
and take over at Hogwarts. Dumbledore saw 
through you when you were at school and he 
still frightens you now, wherever you're hiding
these days.

Turns into...

Sorry to disappoint ye and all that, 
but t' greatest wizard in t' world be 
Albus Dumbledore! Everyone says so! Arrr! Even 
when ye were strong, ye didn't dare try 
and take over at Hogwarts! Dumbledore saw 
through ye when ye were at school and he 
still frightens ye now, wherever ye be hidin'
these days! Arrr!

Submit this is pirate
Comments