Question
1. Implement the following functions def normalize(input_string): input: a string of text characters. Each character is called a token. output: an array of 'letters'. Each
1. Implement the following functions
def normalize(input_string):
-
input: a string of text characters. Each character is called a token.
-
output: an array of 'letters'. Each item in the array corresponds to a letter in input_string (in lowercase)
-
for example, the input "O.K. #1 Python!" would generate the following list: ['o','k','p','y','t','h','o','n']
-
look at the documentation for string functions; don't try to replace, delete, or substitute -- if the 'token' is a letter it passes the test.
def find_missing_letters(sentence):
-
the input sentence is an array/list (created from normalize())
-
returns a sorted array of letters that are NOT in the sentence
-
use the built in Python type set to solve (see previous lesson)
def find_missing_letters_algorithm(sentence):
-
the input sentence is an array/list (created from normalize())
-
returns a sorted array of letters that are NOT in the sentence
-
you must NOT use the set type
implement the function pipeline(), which pipes the output of each step in the pipeline process into the next stage. For example, if you had the functions a1, b2, c3, pipeline would just do something like return c3(b2(a1())).
-
The answer should read (inside out) and be a single line of code.
-
You can use either find_missing_letters_algorithm or find_missing_letters since both return the same output.
-
Your final stage should be calling visualize (already done)
starter code
import lesson
def test_missing_letters(): sentence = lesson.normalize("I am missing many letters") s = lesson.find_missing_letters(sentence) print(s)
# First test your implementation test_missing_letters()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started