Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help !!!!! I really do not how to start it. Python !!!! Write the function countWords(txt), where txt is a string. This function returns

Need help !!!!! I really do not how to start it.

Python !!!!

Write the function countWords(txt), where txt is a string. This function returns a dictionary whose keys are included words, and values their word counts. Count contraction words as (cant), (dont), (isnt), etc. If a string is not provided as an input, the function must return a string withan error message (the string error is enough).

Hint: Remove punctuation before counting the words, careful with contraction words

[5 pts] Write the function studentGrades(gradeList) that takes a nested list with the following structure:

  • - First list is always a descriptive header.

  • - Subsequent lists hold all the data.

  • - For lists that hold data, the first element is always a string, the rest of the elements are

    numeric values. Each list (except for the first one) represents the grades of the student and the first element of each list contains the name of the student.

    grades = [

    ['Student', 'Quiz 1', 'Quiz 2', 'Quiz 3'],# List 1, header['John', 100, 90, 80], ['McVay', 88, 99, 111], ['Rita', 45, 56, 67],

    ['Ketan', 59, 61, 67], ['Saranya', 73, 79, 83], ['Min', 89, 97, 101]]

and returns ONE list with the average score for each student in INTEGER format. If a list is not provided as an input, the function must return a string with an error message (the string error isenough) Hint: The method sum adds all the numeric elements of a list (sum([1,2,8.1]) returns 11.1).

def countWords(txt): """ >>> article1=''' ... He will be the president of the company; right now ... he's a vice president. ... But he ..... himself, is no sure of it... ... (Later he will see the importance of these 3.) ... ''' >>> expected={'he': 3,"he's": 1, 'will': 2, 'be': 1, 'the': 3, 'president': 2, 'of': 3, 'company': 1, 'right': 1, 'now': 1, 'is': 1, 'a': 1, 'vice': 1, 'but': 1, 'himself': 1, 'no': 1, 'sure': 1, 'it': 1, 'later': 1, 'see': 1, 'importance': 1, 'these': 1} >>> countWords(article1)==expected True >>> countWords(55) 'error' >>> countWords([3.5,6]) 'error' """ # --- YOU CODE STARTS HERE def studentGrades(gradeList): """ >>> grades = [ ... ['Student', 'Quiz 1', 'Quiz 2', 'Quiz 3'], ... ['John', 100, 90, 80], ... ['McVay', 88, 99, 111], ... ['Rita', 45, 56, 67], ... ['Ketan', 59, 61, 67], ... ['Saranya', 73, 79, 83], ... ['Min', 89, 97, 101]] >>> studentGrades(grades) [90, 99, 56, 62, 78, 95] >>> grades = [ ... ['Student', 'Quiz 1', 'Quiz 2'], ... ['John', 100, 90], ... ['McVay', 88, 99], ... ['Min', 89, 97]] >>> studentGrades(grades) [95, 93, 93] >>> studentGrades(55) 'error' """ # --- YOU CODE STARTS HERE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions