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

Work 17: 3/19

posted Mar 19, 2019, 11:07 AM by JonAlf Dyrland-Weaver   [ updated Mar 19, 2019, 12:34 PM ]
Write the following functions in a single .py file.

  1. encode_table()
    • Should print out each letter from a-z, along with its UTF-8 value, use one line per character.
    • The function does not need to return anything.
  2. There is a cipher called rot13,  the following image shows how to "encrypt" something in rot13:

    • Look at the Unicode values from encode_table(), what can you tell about a letter and its rot13 equivalent?
  3. Write a function that takes a single character string as a parameter and returns its rot13 equivalent. 
    • for example rot13char("b") would return "o"
  4. Write a function that prints out all the characters from "a" to "z" along with their rot13 equivalents.
    • Like problem 1, each letter should be on its own line.
    • A line of this string might look like: h -> u
  5. Write a function that will take a string consisting of lowercase letters only and will return its rot13 equivalent.
    • For example, rot13("skywalker") would return "fxljnyxre"
    • What happens when you call rot13 on a string that was created by rot13?
  6. Go back to the functions you wrote that takes a single character and returns its rot13 equivalent, modify it such that it now works with both upper and lower case letters.
  7. Modify your function from part 5 so that it can take a string with any characters in it, but will only modify letters, leaving spaces, numbers and punctuation unchanged.

submit this as rot13