Question: def countWords(document): Takes a string as an argument and returns a dictionary with the word count >>> article1=''' ... He will be the president

 def countWords(document): """ Takes a string as an argument and returns
a dictionary with the word count >>> article1=''' ... He will be
def countWords(document):
"""
Takes a string as an argument and returns a dictionary with the word count
>>> article1='''
... He will be the president of the company; right now
... he is a vice president.
... But he ..... himself, is no sure of it...
... (Later he will see the importance of these.)
... '''
>>> article2='''
... Two new vents from the erupting Kilauea volcano on Hawaii
... prompted officials on Tuesday afternoon to order the immediate evacuation of
... residents remaining in Lanipuna Gardens. All 1,700 residents of Leilani Estates,
... as well as the smaller Lanipuna, had previously been ordered to evacuate.
... But that does not mean they all have.
... '''
>>> countWords(article1)
{'he': 4, 'will': 2, 'be': 1, 'the': 3, 'president': 2, 'of': 3, 'company': 1, 'right': 1, 'now': 1, 'is': 2, 'a': 1, 'vice': 1, 'but': 1, 'himself': 1, 'no': 1, 'sure': 1, 'it': 1, 'later': 1, 'see': 1, 'importance': 1, 'these': 1}
>>> countWords(article2)
{'two': 1, 'new': 1, 'vents': 1, 'from': 1, 'the': 3, 'erupting': 1, 'kilauea': 1, 'volcano': 1, 'on': 2, 'hawaii': 1, 'prompted': 1, 'officials': 1, 'tuesday': 1, 'afternoon': 1, 'to': 2, 'order': 1, 'immediate': 1, 'evacuation': 1, 'of': 2, 'residents': 2, 'remaining': 1, 'in': 1, 'lanipuna': 2, 'gardens': 1, 'all': 2, 'leilani': 1, 'estates': 1, 'as': 2, 'well': 1, 'smaller': 1, 'had': 1, 'previously': 1, 'been': 1, 'ordered': 1, 'evacuate': 1, 'but': 1, 'that': 1, 'does': 1, 'not': 1, 'mean': 1, 'they': 1, 'have': 1}
>>> countWords(55)
'Invalid input'
>>> countWords([3.5,6])
'Invalid input'
"""
# --- YOU CODE STARTS HERE
# --- CODE ENDS HERE
def studentGrades(gradeList):
"""
Takes a nested list as an argument and returns a list with the average score for each list in integer format
>>> 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', 'Quiz 3','Final' ],
... ['John', 100, 90, 80, 90],
... ['McVay', 88, 99, 11, 15],
... ['Rita', 45, 56, 67, 89],
... ['Ketan', 59, 61, 67, 32],
... ['Saranya', 73, 79, 83, 45],
... ['Min', 89, 97, 101, 100]]
>>> studentGrades(grades)
[90, 53, 64, 54, 70, 96]
>>> grades = [
... ['Student', 'Quiz 1', 'Quiz 2'],
... ['John', 100, 90],
... ['McVay', 88, 99],
... ['Min', 89, 97]]
>>> studentGrades(grades)
[95, 93, 93]
"""
# --- YOU CODE STARTS HERE
# --- CODE ENDS HERE

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 t [Student ' , 'Quiz 1', 'Quiz 2", t 'John, 100, 90, 80), "Quiz 3:1,# List 1, header I'McVay, 88, 99, 111 'Rita', 45, 56, 67), I 'Ketan', 59, 61, 67 I'Saranya', 73, 79, 83), ['Min, 89, 97, 1011) and returns ONE list with the average score for each student in INTEGER format. Hint: The method sum adds all the numeric elements of a list (sum([1,2,8.1D returns 11.1). qrades I'Student', 'Quiz 1 'Quiz 2 t'John', 100, 90, 801, t 'McVay,88, 99, 1111, 'Rita', 45, 56, 671 t 'Ketan,59, 61, 671, t'Saranya, 73, 79, 83, 'Min', 89, 97, 101]1 Quiz 3. 100 + 90 +80=270 70/3-90 >>> studentGrades (grades) [90, 99,56, 62,78, 951 grades t 'Student, lQui2 , Quiz 2, Quiz 3','Final' t' John', 100, 90, 80, 90. 'McVay', 88, 99. 11. 151. ["Rta", 45, 56, 67, 891, i'Ketan', 59, 62, 67, 321 'Saranya, 73 79,83,451, ['Hin', 89, 97, 101, 100]] 100+90+80+90-360 360/4 90 CMPSC 132 Sylabus (2) pat Group Contract and . docxprogress.report templ...doc lab10-2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!