def report_progress (typed, prompt, id, send) : """Send a report of your id and progress so far to the multiplayer server . "un #...
View the step-by-step solution to:

Question

problem 8 & 9

Screen Shot 2019-10-01 at 4.02.54 PM.png

src="/qa/attachment/10699066/" alt="Screen Shot 2019-10-01 at 4.03.55 PM.png" />Screen Shot 2019-10-01 at 4.04.07 PM.png

Screen Shot 2019-10-01 at 4.02.54 PM.png

def report_progress (typed, prompt, id, send) :
"""Send a report of your id and progress so far to the multiplayer
server . "un
# BEGIN PROBLEM 8
" *** YOUR CODE HERE *<>*>* "!
# END PROBLEM 8
def fastest_words_report (word_times ) :
"" "Return a text description of the fastest words typed by each
player . " " "
fastest = fastest_words (word_times)
report = ' '
for i in range (len(fastest) ) :
words = ' , '. join(fastest[i])
report += 'Player {} typed these fastest: {}\n' . format(i + 1,
words)
return report
def fastest_words (word_times, margin=le-5) :
"""A list of which words each player typed fastest."ull
n_players = len(word_times)
n_words = len(word_times[0]) - 1
assert all(len (times ) == n_words + 1 for times in word_times)
assert margin > 0
# BEGIN PROBLEM 9
" ** YOUR CODE HERE *<>*>* "
# END PROBLEM 9

Screen Shot 2019-10-01 at 4.03.55 PM.png

Problem 8 (2 pt) Implement report_progress , which is called every time the user finishes typing a word. It takes a
list of the words typed , a list of the words in the prompt , the user id, and a send function that
is used to send a progress report to the multiplayer server. Your progress is a ratio of the words in the prompt that you have typed correctly, up to the first
incorrect word, divided by the number of prompt words. For example, this example has a
progress of 6.25: report_progress(["Hello", "ths", "15"], ["Hello", "this", 15", "wrong"], ...) Your report_progress function should return this number. Before that, it should end a message
to the multiplayer server that is a two-element dictionary containing the keys 'id' and
'progress' . The id is passed into report_progress from the GUI. The progress is the fraction
you compute. Call send on this dictionary to send it to the multiplayer server.

Screen Shot 2019-10-01 at 4.04.07 PM.png

Problem 9 (3 pt) Implement fastest_words , which returns which words each player typed fastest. This function is
called once both players have finished typing. It takes word_times and a positive margin . The word_times argument is a list of lists of word_time values, one list for each player, and
within each list n+1 elements for the total elapsed time in the race after that player has finished
typing each of the n words, as well as an entry at the beginning with zero elapsed time for the
special word 'START' . It returns a list of lists of words, one list for each player, and within each list the words they
typed the fastest. Definition: A player typed a word the fastest if the difference between their elapsed time for that
word and the previous word is within margin of the smallest difference for any player. Therefore,
if two players type a word within margin of each other, that word will appear in both of their
lists. Be sure to use the word and e1apsed_time accessor functions for the word_time data
abstraction, rather than assuming a particular data format.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes