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()")
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...
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()")
"""
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
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
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.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr