Compsci 101, Fall 2015, October 29-1
Sign in to Google to save your progress. Learn more
Names
netid
netid
netid
netid
These questions based on function countup from Counter.py
def countup(words):
    pairs = [(w,words.count(w)) for w in words]
    return sorted(set(pairs))
Which one of the following is true?
Clear selection
In the code above, how many times is words.count called if the parameter words contains 100 strings?
Clear selection
The function call words.count(w) must examine every string in words to see if it's equal to w in returning a count. If words contains 100 strings, how many times is words[0] checked to see if it's equal to a string w across all the calls of words.count(w)
Clear selection
If instead of creating a set in the return statement, the list comprehension is changed to using a set as shown below, which of the following are true about the code (more than one statement may be true)?
pairs = [(w,words.count(w)) for w in set(words)]
Submit
Clear form
Never submit passwords through Google Forms.
This content is neither created nor endorsed by Google. Report Abuse - Terms of Service - Privacy Policy