Python Programming

Untitled Forums Programming Assignment Help Python Programming

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2825
    Aakanksha
    Participant

    plz help me in my assignment

    We want to encode text files to keep the data private. Write a program that does the following:

    • Read a text file (check for exceptions) and print the contents of the file (as one long string)

    • Analyse the encoding instructions

    • Apply the encoding instructions to the contents of the file

    • Write the contents to a new file

    • Open the new file and print its contents

    The encoding instructions will be given in the form “ae;ea;s3”.

    For this example this would mean to change ‘a’ to ‘e’, change ‘e’ to ‘a’ and change ‘s’ to ‘3’.

    Your program needs to also work with any other encoding instructions provided.

    The new file must have the old filename with the word “Encoded” added to the basic name.

    For example, “message.txt” will become “messageEncoded.txt”.

    The first line of your main function must look like this:

    def encode(pattern, filename) :

    An example output would look like this:

    >>> encode(“ae;ea;s3”, “F:\message.txt”)

    This is a test message

    Change a to e

    Change e to a

    Change s to 3

    Thi3 i3 e ta3t ma33ega

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.