Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Practice programming with dictionaries, strings, loops, and functions. You are given a dictionary crypt of type [String:String] which has values for all lowercase letters.

Objective:Practice programming with dictionaries, strings, loops, and functions.

You are given a dictionarycryptof type[String:String]which has values for all lowercase letters. Thecryptdictionary represents a way to encode a message. For example, ifcrypt["h"] = "@"andcrypt["i"] = "!"the encoded version of the message"hi"will be"@!".

Part 1:Write code that would take any string containing only lower case letters and spaces and encode it using thecryptdictionary (non-lower case letters can be encoded into themselves).

Use the followingcryptdictionary to test your code with the string message "hello swift":

================= varcrypt = [ "a" : "$", "b" : "&", "c" : "", "d" : "*", "e" : "%", "f" : "", "g" : ")", "h" : "@", "i" : "!", "j" : ">", "k" : "<", "l" : "{", "m" : "}", "n" : "?", "o" : "/", "p" : "", "q" : "-", "r" : "", "s" : "~", "t" : "", "u" : ".", "v" : "[", "w" : "]", "x" : "|", "y" : ":", "z" : "_", " ": "" ]

Sample input:crypto swift

Expected Output::/~]!

Part 2:Write a function that takes a string and returns its encoded version using the crypt dictionary. Test your function with few samplestrings including the sample input above.

Deliverables:Submit (1) a copy of your code for Part 2 (be sure to put your name and indicate which part of the assignment you completed), (2) screen shot of at least two test cases showing your solution meets problem specs above.

the first coding gave some build in errors.

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

12-5 How will MIS help my career?

Answered: 1 week ago