Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

What is utilization in a manufacturing plant? Provide a definition.

Answered: 1 week ago

Question

4. Is Uber a viable business? Explain your answer.

Answered: 1 week ago

Question

3. You can gain power by making others feel important.

Answered: 1 week ago