Question
q1 Write a function decodeString() that takes a string. Decode your string it via dictionary below. answers = {A: S, B: X, F: D, G:R,
q1
Write a function decodeString() that takes a string. Decode your string it via dictionary below. answers = {"A": "S", "B": "X", "F": "D", "G":"R", "K": "L", "S": "M", "P":"T", "X":"E", "Y":"C"} Note: If a char is not in the dictionary decode as "?" Write Python statements that ask the user to input a word, then call the method and print the returned result.
q2
Write a function printStocks() that gets a dictionary as explained below, loops through each element and prints out the key along with its price and stock information. The output will be in the format shown below. Create a empty dictionary called "stocks" using {} format. The key of this dictionary is name of an item and the value is a list containing two numbers (first element of that list is stock and second element is relevant price). Put the following values in your "stocks" dictionary: "banana": [4, 5], "apple": [2, 2], "orange": [1.5, 2.5], "pear": [3, 4] Call the printStocks() function to print the stocks. Then find and print the total value of the stocks. The value of each item is computed by multiplying the stock value by price value.
q3
Write a function removeDuplicates() that gets a list as parameter, and return a new list in which the duplicate items are removed. (While removing duplicated items in the list, print those items. +5 pts.) Write Python statements that create a list with [4, 8, 15, "aero", 4, 23, "aero", 2, 1, 19, 1, 1, 8], call removeDuplicates() function and print final list as shown in the sample run below.
Please write the code rather than taking screenshot of it!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started