1. Engineering
  2. Computer Science
  3. 2nd picture is of doctests which all must be passed10...

Question: 2nd picture is of doctests which all must be passed10...

Question details

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 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 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], IMin, 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 hes a vice president. But he... himself, is no sure of it... (Later he will see the importance of these 3.) >>expected-ihe 3, hes: 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[ IStudent, Quiz 1, Quiz 2, Quiz 3, John, 100, 90, 801, [ McVay, 88, 99, 111, Rita, 45, 56, 671, I Ketan, 59, 61, 671, ISaranya, 73, 79, 83, [Min, 89, 97, 1011] >>> studentGrades (grades) [90, 99, 56, 62, 78, 95] >>>grades[ IStudent, Quiz 1, Quiz 2, John, 100, 90], [McVay, 88, 99], IMin, 89, 9711 >>> studentGrades (grades) 195, 93, 93] >>> studentGrades (55) error

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution