How do I implement a function that calculates the score for a single word using the following code:   def test_get_word_score():     """     Unit test for get_word_score     """     failure=False     # dictionary of words and scores     words = {("", 7):0, ("it", 7):2, ("was", 7):54, ("weed", 6):176,              ("scored", 7):351, ("WaYbILl", 7):735, ("Outgnaw", 7):539,              ("fork", 7):209, ("FORK", 4):308}     for (word, n) in words.keys():         score = get_word_score(word, n)         if score != words[(word, n)]:             print("FAILURE: test_get_word_score()")             print("\tExpected", words[(word, n)], "points but got '" + \                   str(score) + "' for word '" + word + "', n=" + str(n))             failure=True     if not failure:         print("SUCCESS: test_get_word_score()")

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question
How do I implement a function that calculates the score for a single word using the following code:
 
def test_get_word_score():
    """
    Unit test for get_word_score
    """
    failure=False
    # dictionary of words and scores
    words = {("", 7):0, ("it", 7):2, ("was", 7):54, ("weed", 6):176,
             ("scored", 7):351, ("WaYbILl", 7):735, ("Outgnaw", 7):539,
             ("fork", 7):209, ("FORK", 4):308}
    for (word, n) in words.keys():
        score = get_word_score(word, n)
        if score != words[(word, n)]:
            print("FAILURE: test_get_word_score()")
            print("\tExpected", words[(word, n)], "points but got '" + \
                  str(score) + "' for word '" + word + "', n=" + str(n))
            failure=True
    if not failure:
        print("SUCCESS: test_get_word_score()")
 
 
 
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr