![sonyav732](/avatars/8205.jpg)
sonyav732
14.02.2020 •
Computers and Technology
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,
Solved
Show answers
More tips
- H Health and Medicine What is Autism? Understanding the Basics of This Neurodevelopmental Disorder...
- F Family and Home How to Properly Use a Water Level?...
- D Dating, Love, Relationships 10 Useful Tips on How to Survive a Breakup?...
- F Food and Cooking Apple Cider Vinegar: The Ultimate Health and Beauty Solution...
- C Computers and Internet Е-head: How it Simplifies Life for Users?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
Answers on questions: Computers and Technology
- C Computers and Technology Anne creates a web page and loads a CSS style script along with the page. However, the entire page appears black and she cannot see any of the text she has entered....
- C Computers and Technology One of the advantages of capitalism system is...
- C Computers and Technology What is the difference between a 13 column abacus and 5 column abacus?...
- C Computers and Technology Tik T ok friend *got to se nd vide os and ha ve them *con tent mu st be interes ting *at least 1 k or 100 follow ers *must be an active us er * got ta be at least 14^...
- M Mathematics Which of the following shows a factor of 100b2 - 144a4? a. 10b - 12a b. 10b + 12a c. 10b + 12a2 d. 50b - 72a2...
- P Physics According to aristotle what kind of motion requires no force...
- M Mathematics The original price is f an item is $25, but after the discount, you only have to pay $18.50. whats is the discount ( as a percent)?...
- M Mathematics Which simplified fraction is equal to 0.17 (7 is repeating) a.9/17 b.8/45 c.17/9 d.16/90...
- H History What factor led to nixon’s re-election in 1972...
- E English If you were looking at a dictionary entry for the word sadism, which of these is the most likely list of information you would find? a) the pronunciation, the part...
Ответ:
answer would be