#================================================== # Problem 0 # Write a function, encode_table(), that should print out # each letter from a-z, along with its UTF-8 value, use one line per character. # Each line should look like this: # a: 97 # The function does not need to return anything. def encode_table(): count=ord('a') while count'z' or 'a'>c: return c c13=ord(c)+13 if c13>ord('z'): return chr(c13-26) return chr(c13) print(('=' * 10) + "Problem 2" + ('=' * 10)) print( 'b: ' + rot13char('b') ) print( 'q: ' + rot13char('q') ) print( '?: ' + rot13char('?') ) # End Problem 2 #================================================== #================================================== # Problem 3 # Write a function that prints out all the characters # from 'a' to 'z' along with their rot13 equivalents. # Like problem 0, each letter should be on its own line. # A line of this string might look like: # h -> u def rot13_table(): count=ord('a') while count "+rot13char(chr(count))) count+=1 print(('=' * 10) + "Problem 3" + ('=' * 10)) rot13_table() # End Problem 3 #================================================== #================================================== # Problem 4 # 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" def rot13(s): count=0 out='' while count ' + rotted ) # What happens when you call rot13 on a string that was created by rot13? # print out your answer as a string answer = '' print(answer) # End Problem 4 #================================================== #================================================== # Problem 5 # Go back to problem 2, create a new version below such # that it now works with both upper and lower case letters. def rot13char_anycase(c): if 'a'<=c<='z': rot13char(c) # Test your function here print(('=' * 10) + "Problem 5" + ('=' * 10)) print(rot13char_anycase(A)) # End Problem 5 #================================================== #================================================== # Problem 6 # Write a function that can take a string with any # characters in it, but will only modify letters, # leaving spaces, numbers and punctuation unchanged. # # Hint: If you've gotten to this point, most of the # work has already been done. def rot13_full(s): return s # Test your function here print(('=' * 10) + "Problem 6" + ('=' * 10)) # End Problem 6 #==================================================