Comment(s): Great job writing all valid Python code without any errors or issues! I tested each one of your functions and class and in all cases received some form of output and no translation errors.
Criteria 2: Implementation of Project Requirements
Score Level: 3/4
Comment(s): Nice job implementing each of the required set of functions and class for this project! Hopefully this programming "game" highlighted some of the ways that you might use Python for data analysis and discovery. I did find a few issues in your implementation which I discuss below.
get_average_sentence_length should return the average number of words per sentence instead of the average number of characters per sentence (which is what your implementation is calculating). The main different is that for each sentence you should split into individual words, then store the number of words in each sentence. Here is an example of the correct implementation.
def get_average_sentence_length(text):
no_questions = text.replace('?', '.')
no_exclaim = no_questions.replace('!', '.')
sentences = list(filter(None, no_exclaim.split('.')))
sentence_lengths = []
for sentence in sentences:
words = sentence.split()
sentence_lengths.append(len(words))
average = sum(sentence_lengths) / len(sentences)
return average
One other thing to note is that split('.') returns a list with an empty last index because the final sentence ends with a period. So in order to get the correct result we need to ensure that this is filtered out. Lastly, don't forget that sentences can often end with other valid characters such as ? and !. So be sure to replace these with a period in order to not skew the results.
Be sure to checkout the below review section (Criteria 4) for some recommendations and feedback on how you might further improve your Python skills
Criteria 3: Software Architecture
Score Level: 4/4
Comment(s): Though the project requirements instructed you to break apart your implementation into separate functions and classes, I'm glad to see that you followed through on this requirement! Hopefully this basic software architectural approach provided you with some guidance on how to structure code in the future. Imagine if you had been asked to solve this problem in one fail swoop, it would certainly have been much more challenging to do. As a result your implementation would have most likely been much less extensible, maintainable, and verifiable (e.g. the ability to test small chunks of functionality). Please keep this in mind as you continue using Python in the future!
Criteria 4: Uses Python Language Features
Score Level: 4/4
Comment(s): Very nice job taking advantage of many built-in language functions and features! Since there is always room for improvement, I have shared a few recommendations and feedback on your implementation below.
I would recommend always using triple quotes for long strings. They offer more safety and flexibility in that they allow for multi-line strings.
Great job on your prepare_text and build_frequency_table implementations! I loved your efficient use of built in functions and language features. Very nicely done!!
Criteria 5: Produces Accurate Output
Score Level: 4/4
Comment(s): Great job, all of your output was accurate and you correctly identified the murderer!
Overall Score: 19/20
Overall you did a fantastic job on this project! I can tell that you have learned a lot from the PWP course and hope you continue on with your Python journey.
Rubric Score
Criteria 1: Valid Python Code
Criteria 2: Implementation of Project Requirements
get_average_sentence_length
should return the average number of words per sentence instead of the average number of characters per sentence (which is what your implementation is calculating). The main different is that for each sentence you should split into individual words, then store the number of words in each sentence. Here is an example of the correct implementation.One other thing to note is that
split('.')
returns a list with an empty last index because the final sentence ends with a period. So in order to get the correct result we need to ensure that this is filtered out. Lastly, don't forget that sentences can often end with other valid characters such as ? and !. So be sure to replace these with a period in order to not skew the results.Be sure to checkout the below review section (Criteria 4) for some recommendations and feedback on how you might further improve your Python skills
Criteria 3: Software Architecture
Criteria 4: Uses Python Language Features
I would recommend always using triple quotes for long strings. They offer more safety and flexibility in that they allow for multi-line strings.
Great job on your
prepare_text
andbuild_frequency_table
implementations! I loved your efficient use of built in functions and language features. Very nicely done!!Criteria 5: Produces Accurate Output
Overall Score: 19/20
Overall you did a fantastic job on this project! I can tell that you have learned a lot from the PWP course and hope you continue on with your Python journey.
Keep up the great work!