Question: Write and test the following function: def shift(string, n): ------------------------------------------------------- Encipher a string using a shift cipher. Only letters are enciphered, and the returned
Write and test the following function:
def shift(string, n): """ ------------------------------------------------------- Encipher a string using a shift cipher. Only letters are enciphered, and the returned string is in upper case. Use: estring = shift(string, n): ------------------------------------------------------- Parameters: string - string to encipher (str) n - the number of letters to shift (int) Returns: estring - the enciphered string (str) ------------------------------------------------------- """
Add this function to the PyDev module functions.py. Test it from .
This function uses a shift cipher in which each letter is replaced by another letter that is n positions to the right of the first letter. (A shift of 26 would leave the original string unchanged.) The function should work with an empty string.
Test this function using the file pelee.txt. Write the encrypted text to a file named shift.txt.
pelee.txt
It appears that Ontario's Point Pelee National Park has lost its point. The southernmost tip of Canada is in the park, near the town of Leamington. There have always been several hundred metres of sand jutting out from the mainland. But park officials say recent high winds have washed away the sand point and all that remains is a platform. The park advertises itself as the southernmost tip of Canada's mainland, at the same latitude as northern California, and attracts more than 400,000 visitors per year. A park official says a no swimming sign that used to mark the southernmost point washed up on a beach in Madison, Ohio, about 100 kilometres across Lake Erie. Officials say the sand patterns at the point change frequently, but this is the first time the point has disappeared completely.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
