Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define the get_text_valuation() function which is passed two parameters, a dictionary and a string of text. The keys of the parameter dictionary are single

"""

Define the get_text_valuation() function which is passed two parameters, a dictionary and a string of text. The keys of the parameter dictionary are single letters and the corresponding values are integers (the value of the key letter), e.g., {'b': 5, 'a': 6, 'c': 3}. The function returns the total valuation (an integer) of the string of text where:

if the letter from the text is a keyletter of the dictionary then its value is the integer corresponding to the letter in the dictionary.

any alphabetic characters from the text which are not in the dictionary are worth 1,

and, all non alphabetic characters are worth 0 (use the isalpha() method to

 check if a character is alphabetic or not). 

Notes:

you will need to change the text to lowercase before you work out the total value of the text,

you can assume that all the keys in the dictionary are lowercase characters.

For example, the following code: letter_value_dict = {"r": 2, "s": 2, "h":4, "t":3, "m": 7, "g":4, "v":8}

letters = "BLAH" print("1.", letters, "-", get_text_valuation(letter_value_dict, letters))

letters = 'thought provoking' 
print("2.", letters, "-", 
letters = "too much month print("3.", letters, "-", 

prints:

get_text_valuation(letter_value_dict, letters))

at the end of the money" get_text_valuation(letter_value_dict, letters))

1. BLAH - 7 2. thought provoking - 40 3. too much month at the end of the money - 70 """ def get_text_valuation(letter_worth_dict, text):

return 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxiv Special Issue On Database And Expert Systems Applications Lncs 9510

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Hendrik Decker ,Lenka Lhotska ,Sebastian Link

1st Edition

366249213X, 978-3662492130

More Books

Students also viewed these Databases questions

Question

How is the moral hazard problem relevant to the health care market?

Answered: 1 week ago

Question

Explain how the different reinforcement schedules affect behavior.

Answered: 1 week ago

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago