subject

The three functions below all concern a functional way to store a dictionary. We store a dictionary as a tuple of 2-tuples: index 0 of each 2-tuple is a key; index 1 is that key's associated value. The order of the keys is irrelevant, but keys are unique: no 2-tuples can have the same keys. For example the dictionary {'a': 1, 'b': 2, 'c': 3} might be stored as (('b',2), ('a',1), ('c', 3)) -or any other tuple with these 2-tuples in any order. We call such a data structure an association tuple. • Define a recursive function named get_assoc; it is passed an association tuple and key as arguments; it returns the value in the association tuple associated with the key. If the key is not in the association tuple, raise the KeyError exception. • Define a recursive function named del_assoc; it is passed an association tuple and key as arguments; it returns an association tuple that contains all associations except the one specified by the key parameter (keep the order of the other keys in the association tuple the same). If the key is not in the association tuple, raise the ReyError exception. Hint: build a new association tuple with all associations but the deleted one. • Define a recursive function named set_assoc; it is passed an association tuple, key, and associated value as arguments; it returns an association tuple that contains all associations with (a) a new 2-tuple added at the end for this association (if the key is nowhere in the association tuple) or (b) one of the associations changed (if the key is already in the tuple). Keep the key order the same. For example,

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:00
Give an example of a case where a two-way handshake to establish a connection could leave one side of the connection live while the other side does not believe there is a connection.
Answers: 1
question
Computers and Technology, 22.06.2019 08:00
Aplan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedule.
Answers: 1
question
Computers and Technology, 22.06.2019 12:00
Which of the following does 3d animation create an illusion of on the screen? a. depth b. emotion c. length d. dialogue
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
As with any small island country, cuba has fewer natural resources than countries such as brazil. this affects their economy in that cuba a) exports only manufactured products. b) exports more products than it imports.. c) must import more products than it exports. d) has imposed trade barriers against the united states.
Answers: 3
You know the right answer?
The three functions below all concern a functional way to store a dictionary. We store a dictionary...
Questions
question
Mathematics, 07.10.2021 01:00
question
Mathematics, 07.10.2021 01:00
question
Mathematics, 07.10.2021 01:00