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
32 changes: 22 additions & 10 deletions exercises/concept/little-sisters-essay/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
def capitalize_title(title):
"""Convert the first letter of each word in the title to uppercase if needed.

:param title: str - title string that needs title casing.
:return: str - title string in title case (first letters capitalized).
Parameters:
title (str): Essay title that needs title casing.

Returns:
str: The title string in title case (first letters capitalized).
"""

return title.title()
Expand All @@ -14,8 +17,11 @@ def capitalize_title(title):
def check_sentence_ending(sentence):
"""Check the ending of the sentence to verify that a period is present.

:param sentence: str - a sentence to check.
:return: bool - is the sentence punctuated correctly?
Parameters:
sentence (str): A sentence to check.

Returns:
bool: Is the sentence punctuated correctly?
"""

return sentence.endswith(".")
Expand All @@ -24,8 +30,11 @@ def check_sentence_ending(sentence):
def clean_up_spacing(sentence):
"""Trim any leading or trailing whitespace from the sentence.

:param sentence: str - a sentence to clean of leading and trailing space characters.
:return: str - a sentence that has been cleaned of leading and trailing space characters.
Parameters:
sentence (str): A sentence to clean of leading and trailing space characters.

Returns:
str: A sentence that has been cleaned of leading and trailing space characters.
"""

clean_sentence = sentence.strip()
Expand All @@ -35,10 +44,13 @@ def clean_up_spacing(sentence):
def replace_word_choice(sentence, old_word, new_word):
"""Replace a word in the provided sentence with a new one.

:param sentence: str - a sentence to replace words in.
:param old_word: str - word to replace.
:param new_word: str - replacement word.
:return: str - input sentence with new words in place of old words.
Parameters:
sentence (str): A sentence to replace words in.
old_word (str): The word to replace.
new_word (str): The replacement word.

Returns:
str: Input sentence with new words in place of old words.
"""

better_sentence = sentence.replace(old_word, new_word)
Expand Down
34 changes: 23 additions & 11 deletions exercises/concept/little-sisters-essay/string_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
def capitalize_title(title):
"""Convert the first letter of each word in the title to uppercase if needed.

:param title: str - title string that needs title casing.
:return: str - title string in title case (first letters capitalized).
Parameters:
title (str): Essay title that needs title casing.

Returns:
str: The title string in title case (first letters capitalized).
"""

pass
Expand All @@ -14,18 +17,24 @@ def capitalize_title(title):
def check_sentence_ending(sentence):
"""Check the ending of the sentence to verify that a period is present.

:param sentence: str - a sentence to check.
:return: bool - return True if punctuated correctly with period, False otherwise.
Parameters:
sentence (str): A sentence to check.

Returns:
bool: Is the sentence punctuated correctly?
"""

pass


def clean_up_spacing(sentence):
"""Verify that there isn't any whitespace at the start and end of the sentence.
"""Trim any leading or trailing whitespace from the sentence.

:param sentence: str - a sentence to clean of leading and trailing space characters.
:return: str - a sentence that has been cleaned of leading and trailing space characters.
Parameters:
sentence (str): A sentence to clean of leading and trailing space characters.

Returns:
str: A sentence that has been cleaned of leading and trailing space characters.
"""

pass
Expand All @@ -34,10 +43,13 @@ def clean_up_spacing(sentence):
def replace_word_choice(sentence, old_word, new_word):
"""Replace a word in the provided sentence with a new one.

:param sentence: str - a sentence to replace words in.
:param old_word: str - word to replace.
:param new_word: str - replacement word.
:return: str - input sentence with new words in place of old words.
Parameters:
sentence (str): A sentence to replace words in.
old_word (str): The word to replace.
new_word (str): The replacement word.

Returns:
str: Input sentence with new words in place of old words.
"""

pass
Loading