Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

22a. decipher.py Write a function decipher(codex, secret_message) that uses the dictionary codex to decode secret message . For example: codex = { s : i

22a. decipher.py

Write a function decipher(codex, secret_message) that uses the dictionary codex to decode secret message.

For example:

codex = {"s": "i",  "y": "a",  "e": "m",  "q": "g",  "p": "r",  "n": "o",  "t": "t"}  decipher(codex, "S ye Qpnnt!")

Would return:

I am Groot!

b. auto_correct.py

Write a function auto_correct(correct_words,text) where correct_words is a dictionary that maps commonly misplelled words to their correct spelling. Use correct words to autocorrect any applicable mispellings in text.

correct_words= {"Teh": "The",  "mispelled": "misspelled",  "corects": "corrects"}  auto_correct(correct_words, "Teh function corects mispelled words!")

Would return:

The function corrects misspelled words!

c. shopping_cart_total.py

Write a function shopping_cart_total(cart, prices) where cart is a dictionary that maps shopping items to the quantity bought (eg. forks: 4) and prices is a dictionary that maps store items to how much they cost (eg. milk: 2.99). Use cart and prices to compute the total cost of all items in the cart.

For example:

cart = {"apple": 3, "soup": 5, "ramen": 3, "milk": 1} prices = {"apple": 1, "soup": 3, "ramen": 1, "milk": 2}  shopping_cart_total(cart, prices)

Would return:

23

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

Is there an optimal capital structure under the MM zero-tax model?

Answered: 1 week ago