Question: Write, test and document a Python program, in a file called Encodehiords.py, which includes and tests functions to solve the following problem: Given a number
Write, test and document a Python program, in a file called Encodehiords.py, which includes and tests functions to solve the following problem: Given a number of words as input, encode the given word and generate the desired output with appropriate labels. Note: The given input words should be at least 4 characters long otherwise a message indicating the error should be printed. For example, with the given input prompts and given input words, the output from the program would be as follows: Please enter a word (zzz to finish): that The original given word is: that The encoded word is: ttha Please enter a word (zzz to finish): car The word cannot be processed as it is not at least four characters long Please enter a word (zzz to finish): mouse The original given word is: mouse The encoded word is: neosuu Please enter a word (zzz to finish): computer The original given word is: computer The encoded word is: croemtpu Please enter a word (zzz to finish): zz2 Use (at least) the following functions to solve the problem: a. Function encode Theword which takes a word and returns an encoded word as follows: the first character of the word is followed by the last character of the word which is followed by the second character and then the second last character of the word and so on. For example, given the word that the function should return ttha. If the given word has an odd number of characters, then the middle character is repeated again. For example, given the word souse it should be encoded as neosu b. Function sain which tests the function(s) and prints the required data with appropriate labels as shown in the output above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
