a) Write a function that takes a string as its argument
If the word is 4 characters or shorter, return the argument inUPPERCASE. If the word is 4 letters or longer, return the word inlowercase.
EX:
process_word(“The”) # returns ‘THE’
process_word(“Answer”) # returns ‘answer’
# hint .upper(), .lower()
b) Write a second function that takes a string of a sentence,splits it into multiple words, applies the first function to eachword, and then returns a new string of the processed sentence.
EX:
sentence = “Four score and seven years ago our fathers broughtforth, on this continent, a new nation, conceived in Liberty, anddedicated to the proposition that all men are created equal.”
print(process_sentence(sentence))
# would print:
# FOUR score AND seven years AGO OUR fathers brought forth, ON THIScontinent, A NEW nation, conceived IN liberty, AND dedicated TO THEproposition THAT ALL MEN ARE created equal.
# hint: .split(), map(function, list), ” “.join(list)
Now try to prompt the user for an input and print the processedstring.
Expert Answer
Answer to a) Write a function that takes a string as its argument If the word is 4 characters or shorter, return the argument in U…