Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2nd picture is of doctests which all must be passed(10 total). [5 pts] Write the function countWords(txt), where txt is a string. This function returns

2nd picture is of doctests which all must be passed(10 total).

image text in transcribed

image text in transcribed

[5 pts] 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 (can't), (don't), (isn't), etc. If a string is not provided as an input, the function must return a string with an 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 I [Student', 'Quiz 1., ,Quiz 2', 'John, 100, 90, 801, 'McVay', 88, 99, 1111, ['Rita', 45, 56, 67, [ 'Ketan', 59, 61, 671, 'Saranya, 73, 79, 83], I'Min', 89, 97, 10111 'Quiz 3'],# List 1, header 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' is enough) Hint: The method sum adds all the numeric elements of a list (sum([1,2,8.1]) returns 11.1). def countWords (txt): >articlel-*" .. . 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-i'he' 3, "he's": 1, 'will': 2, 'be': 1, 'the' 3, 'president' 2, 'of' 3, 'company': 1, 'right': 1, ow: 1,is 1, 'vice' 1, 'but' 1, 'himself' 1, 'no' 1, 'sure': 1, 'it 'later': 1, 'see': 1, 'importance' 1, 'these' 1) ': 1, 'a': ': 1, >countWords (articlel)-expected True >> countWords (55) 'error' > countWords ([3.5,6]) error' YOU CODE STARTS HERE def studentGrades (gradeList): >>> grades[ I'Student', 'Quiz 1', 'Quiz 2', 'Quiz 3', 'John', 100, 90, 801, [ 'McVay, 88, 99, 111, 'Rita', 45, 56, 671, I 'Ketan', 59, 61, 671, I'Saranya', 73, 79, 83, ['Min', 89, 97, 1011] >>> studentGrades (grades) [90, 99, 56, 62, 78, 95] >>>grades[ I'Student', 'Quiz 1', 'Quiz 2', 'John', 100, 90], ['McVay', 88, 99], I'Min, 89, 9711 >>> studentGrades (grades) 195, 93, 93] >>> studentGrades (55) error

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

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions

Question

What three forces constitute the triangle of fraud?

Answered: 1 week ago

Question

The Market System as an Efficient Mechanism for Information

Answered: 1 week ago

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago