Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions exercises/concept/little-sisters-vocab/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,34 @@
def add_prefix_un(word):
"""Take the given word and add the 'un' prefix.

:param word: str - containing the root word.
:return: str - of root word prepended with 'un'.
Parameters:
word (str): The root word.

Returns:
str: Root word prepended with 'un'.
"""

return 'un' + word


def make_word_groups(vocab_words):
"""Transform a list containing a prefix and words into a string with the prefix followed by the words with prefix prepended.
"""Transform a list containing a prefix and words.

Parameters:
vocab_words (list[str]): Vocabulary words with prefix at first index.

:param vocab_words: list - of vocabulary words with prefix in first index.
:return: str - of prefix followed by vocabulary words with
Returns:
str: Prefix followed by vocabulary words with
prefix applied.

This function takes a `vocab_words` list and returns a string
This function takes a `vocab_words` list of strings and returns a string
with the prefix and the words with prefix applied, separated
by ' :: '.

For example: list('en', 'close', 'joy', 'lighten'),
produces the following string: 'en :: enclose :: enjoy :: enlighten'.
Examples:
>>> list('en', 'close', 'joy', 'lighten')
'en :: enclose :: enjoy :: enlighten'.

"""

prefix = vocab_words[0]
Expand All @@ -35,10 +43,19 @@ def make_word_groups(vocab_words):
def remove_suffix_ness(word):
"""Remove the suffix from the word while keeping spelling in mind.

:param word: str - of word to remove suffix from.
:return: str - of word with suffix removed & spelling adjusted.
Parameters:
word (str): Word to remove suffix from.

Returns:
str: Word with suffix removed & spelling adjusted.

Examples:
>>> remove_suffix_ness('heaviness')
'heavy'

>>> remove_suffix_ness('sadness')
'sad'

For example: "heaviness" becomes "heavy", but "sadness" becomes "sad".
"""

word = word[:-4]
Expand All @@ -51,11 +68,20 @@ def remove_suffix_ness(word):
def adjective_to_verb(sentence, index):
"""Change the adjective within the sentence to a verb.

:param sentence: str - that uses the word in sentence.
:param index: int - index of the word to remove and transform.
:return: str - word that changes the extracted adjective to a verb.
Parameters:
sentence (str): The word used in a sentence as an adjective.
index (int): Index of the adjective to remove and transform.

Returns:
str: The extracted adjective in verb form.

Examples:
>>> adjective_to_verb('It got dark as the sun set.', 2)
'darken'

>>> adjective_to_verb('The ink stains her fingers black.', -1)
'blacken'

For example, ("It got dark as the sun set", 2) becomes "darken".
"""

word = sentence.split()[index]
Expand Down
56 changes: 41 additions & 15 deletions exercises/concept/little-sisters-vocab/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,34 @@
def add_prefix_un(word):
"""Take the given word and add the 'un' prefix.

:param word: str - containing the root word.
:return: str - of root word prepended with 'un'.
Parameters:
word (str): The root word.

Returns:
str: Root word prepended with 'un'.
"""

pass


def make_word_groups(vocab_words):
"""Transform a list containing a prefix and words into a string with the prefix followed by the words with prefix prepended.
"""Transform a list containing a prefix and words.

Parameters:
vocab_words (list[str]): Vocabulary words with prefix at first index.

:param vocab_words: list - of vocabulary words with prefix in first index.
:return: str - of prefix followed by vocabulary words with
Returns:
str: Prefix followed by vocabulary words with
prefix applied.

This function takes a `vocab_words` list and returns a string
This function takes a `vocab_words` list of strings and returns a string
with the prefix and the words with prefix applied, separated
by ' :: '.

For example: list('en', 'close', 'joy', 'lighten'),
produces the following string: 'en :: enclose :: enjoy :: enlighten'.
Examples:
>>> list('en', 'close', 'joy', 'lighten')
'en :: enclose :: enjoy :: enlighten'.

"""

pass
Expand All @@ -32,10 +40,19 @@ def make_word_groups(vocab_words):
def remove_suffix_ness(word):
"""Remove the suffix from the word while keeping spelling in mind.

:param word: str - of word to remove suffix from.
:return: str - of word with suffix removed & spelling adjusted.
Parameters:
word (str): Word to remove suffix from.

Returns:
str: Word with suffix removed & spelling adjusted.

Examples:
>>> remove_suffix_ness('heaviness')
'heavy'

>>> remove_suffix_ness('sadness')
'sad'

For example: "heaviness" becomes "heavy", but "sadness" becomes "sad".
"""

pass
Expand All @@ -44,11 +61,20 @@ def remove_suffix_ness(word):
def adjective_to_verb(sentence, index):
"""Change the adjective within the sentence to a verb.

:param sentence: str - that uses the word in sentence.
:param index: int - index of the word to remove and transform.
:return: str - word that changes the extracted adjective to a verb.
Parameters:
sentence (str): The word used in a sentence as an adjective.
index (int): Index of the adjective to remove and transform.

Returns:
str: The extracted adjective in verb form.

Examples:
>>> adjective_to_verb('It got dark as the sun set.', 2)
'darken'

>>> adjective_to_verb('The ink stains her fingers black.', -1)
'blacken'

For example, ("It got dark as the sun set.", 2) becomes "darken".
"""

pass
Loading