Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The 3 Fixes Your code will have three different mess-ups it can do to a word. We'll call each of these a fix to the

image text in transcribed
image text in transcribed
image text in transcribed
The 3 Fixes Your code will have three different mess-ups it can do to a word. We'll call each of these a "fix" to the word. Each fix has a name like '-rev' which is just the string used later on the command line to identify that fix. 1. The -rev Fix The-rev fix of a word is made of exactly the same chars, but in reverse order, so abc' becomes 'cba' And 'Happiness.' becomes '.ssenippah' 2. The -mixup Fix The-mixup fix works as follows: separate the word into 3 pieces: the 2 chars prefix at the start of the word, then the middle, then the last char. The mixup of a word is formed by concatenating the prefix, then the reverse of the middle, then the last char. If the word is too short to have separate prefix, middle, and end, the mixup leaves the word unchanged. So for example 'abcde' becomes 'abdce And 'abcdef' becomes 'abedcf' And Happiness.' becomes 'Hassenipp.' 3. The -noe Fix The-noe fix works by using the same chars as the original, but omitting all 'e' chars, upper or lower case. So 'Ethereal' becomes 'thral' And 'Happiness.' becomes 'Happinss.' weo.stanford.edu.classics 105 X C D Not Secure web.stanford.edu And 'abcdef' becomes 'abedef' And 'Happiness.' becomes 'Hassenipp.' 3. The -noe Fix The-noe fix works by using the same chars as the original, but omitting all 'e' chars, upper or lower case. So 'Ethereal' becomes 'thral' And 'Happiness.' becomes 'Happinss.' fix_word() The function fix_word computes the fixed form of a word. The function takes in two strings: an action string which is one of '-rev' '-mixup' '-noe', and a word string like 'Hello', and it returns the result of applying that action to the word. So for example, calls to fix_word() look like fix_word('-rev', 'Hello' -> 'olleh' fix_word('-noe', 'keep') -> 'kp' fix_word('-mixup', 'abcdef') -> 'abedcf We provide the Pydoc specification for fix word. Your challenge is filling in the code and tests to make it work. (For now, ignore the -rand action mentioned in the Pydoc.) def fix_word(action, word): Given action string which should be one of: '-rev', '-mixup', '-noe', -rand And word string. Return the fixed form of the word with that action applied. Return the empty string if the action string is not recognized. pass # TODO: helper functions here def fix_word(action, word): HU Given an action string which should be one of: '-rev', '-mixup', '-noe', '-rand" And a word string. Return the fixed form of the word with that action applied. Return the empty string if the action string is not recognized. pass

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

Students also viewed these Databases questions

Question

Perform an Internet search. Discuss a company that uses EPLI.

Answered: 1 week ago

Question

How do you feel about employment-at-will policies? Are they fair?

Answered: 1 week ago