Python HW with Jupyter Notebook Declare a variable named DATA as a dictionary object. Assign the set...

70.2K

Verified Solution

Question

Programming

Python HW with Jupyter Notebook

  1. Declare a variable named DATA as a dictionary object. Assignthe set of key/value pairs shown below.
  2. Create a function named iter_dict_funky_sum() that takes onedictionary argument.   
  3. Declare a running total integer variable.
  4. Extract the key/value pairs from DATA simultaneously in a loop.Do this with just one for loop and no additional forms oflooping.
  5. Assign and append the product of the value minus the key to therunning total variable.
  6. Return the funky total.

Dictionary Data

DATA = {  2: 7493945,  76: 4654320,  3: 4091979,  90: 1824881,  82: 714422,  45: 1137701,  10: 374362,  0: 326226,  -15: 417203,  -56: 333525,  67: 323451,  99: 321696,  21: 336753,  -100: 361237,  55: 1209714,  5150: 1771800,  42: 4714011,  888: 14817667,  3500: 13760234,  712: 10903322,  7: 10443792,  842: 11716264,  18584: 10559923,  666: 9275602,  70: 11901200,  153: 12074784,  8: 4337229}

Expected Output

>>> iter_dict_funky_sum(DATA)140166242

Answer & Explanation Solved by verified expert
4.5 Ratings (802 Votes)
Code d is the input dictionarydef iterdictfunkysumd total 0 for keyvalue in ditems iterate through dictionary in a    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students