Question

Function Name: zip_d Parameters: two equal-sized lists Returns: a dictionary Description: Write a function, zip_d, that...

Function Name: zip_d
Parameters: two equal-sized lists
Returns: a dictionary

Description: Write a function, zip_d, that takes a two equal-sized lists as parameters, and zips each list into a dictionary.

Sample Inputs/Outputs:

Example Call:  zip_d([1,2,3], ['a','b','c'])
Expected Return:   {1: 'a', 2: 'b', 3: 'c'}
Example Call:  zip_d([‘a’,’b’,’c’],[9.8,7.6,5.4])
Expected Return:  {‘a’:9.8, ’b’:7.6, ’c’:5.4}

please answer in python

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def zip_d(l1, l2):
    d = {}
    for i in range(len(l1)):
        d[l1[i]] = l2[i]
    return d


# Testing the function here. ignore/remove the code below if not required
print(zip_d([1, 2, 3], ['a', 'b', 'c']))
print(zip_d(['a', 'b', 'c'], [9.8, 7.6, 5.4]))

Add a comment
Know the answer?
Add Answer to:
Function Name: zip_d Parameters: two equal-sized lists Returns: a dictionary Description: Write a function, zip_d, that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Function Name: unscramble Parameters: a string Returns: a string Description: Write a function, unscramble, that...

    Python Function Name: unscramble Parameters: a string Returns: a string Description: Write a function, unscramble, that takes an input string, and returns a the unscrambled version of the argument. To unscramble the string: When the string has an odd number of characters, middle character is the first character in the unscrambled result Pairs of remaining characters are added to the result, proceeding left to right from inner-most to outer-most characters. Example Call: unscramble('3cis1') Expected result: ics31 Example Call: unscramble('ocicssol') Expected...

  • Language: Python Topic: Dictionaries Function name: catch_flight Parameters: dictionary, tuple containing two strings Returns: dictionary Description:...

    Language: Python Topic: Dictionaries Function name: catch_flight Parameters: dictionary, tuple containing two strings Returns: dictionary Description: You’ve been stuck in NYC for around 8 months all by yourself because you haven’t been able to find a good time to fly home. You’re willing to go to any city but want to see how many flights to each location fit your budget. You’re given a dictionary that has city names (strings) as the keys and a list of prices (list) and...

  • USE PYTHON / RECURSION METHOD Fibonacci Dictionary Function Name: fibtionary Parameters: num (int) Returns: dictionary (key:...

    USE PYTHON / RECURSION METHOD Fibonacci Dictionary Function Name: fibtionary Parameters: num (int) Returns: dictionary (key: int, value: int) Description: You're done with stats, but you still have other math homework to go! You're currently learning about the Fibonacci sequence in math class. The Fibonacci sequence is a series of numbers in the pattern 112 3 5 8 13 21 ..., where the next number is found by adding up the two numbers before it. Write a function that takes...

  • Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function...

    Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function that takes in a string containing some combination of letters, numbers, and spaces, and return the starting index of the first instance of “waldo” contained in that string. If the string does not contain “waldo”, return -1. This function IS case sensitive, so “waldo” is not the same as “WALDO”. Code using string functions such as .index() and .find() that oversimplify the problem will...

  • pYTHON Exercise: create01 Description Write a function that receives no parameters and returns a Pencil object...

    pYTHON Exercise: create01 Description Write a function that receives no parameters and returns a Pencil object constructed with 3 leads. Function Name create01 Parameters • None Return Value A Pencil object with 3 leads. Example р create01() print(p.get_num_leads()) # -> 3 print(p.get_current_lead_length()) # > 10 Hints • Don't forget to import Pencil.

  • Write a python function that takes a string as input, and returns a dictionary of frequencies...

    Write a python function that takes a string as input, and returns a dictionary of frequencies of all the characters in the string. For example: freq("dabcabcdbbcd") would return {"d":3, "a":2, "b":4, "c":3}. Then write a driver to demonstrate your function.

  • Make a function dict build(keys, values) which takes as argument two lists, one containing keys, one...

    Make a function dict build(keys, values) which takes as argument two lists, one containing keys, one values to be put into a dictionary (in order). If the lists are of the same length put them into a dictionary form, and return the dictionary from the function. Otherwise return the keyword None from the function. For example: Test print(di ct_build(['a', 'b' , 'c'], [1,2,3])={ 'a': 1, 'b': 2, 'c': 3 r example: Result ildCC'a', 'b', 'c'], [1,2,3])-= { 'a': 1, 'b':...

  • Python Function Name: sign_count Parameters: a list of integers Returns: an integer Description: Speed signs should...

    Python Function Name: sign_count Parameters: a list of integers Returns: an integer Description: Speed signs should be posted every mile on a given street. You are given a list of 0s & 1s, where each number represents a quarter of a mile. Thus, every 4 zeroes requires a speed sign. However, a 1 indicates an intersection, and each intersection is automatically required to have a speed limit sign. A sign for each mile proceeds as usual after the intersection. Your...

  • PYTHON PLEASE!! Thank you in advance! 11.56 Lab Exam 3 - factors This section has been...

    PYTHON PLEASE!! Thank you in advance! 11.56 Lab Exam 3 - factors This section has been set as optional by your instructor Function Name: factors Parameters: int Returns: list of int Description: Write a function, factors, that takes an integer n, and returns a list of values that are the positive divisors of n. Note: 0 is not a divisor of any integer, 1 divides every number, and n divides itself Sample Inputs/Outputs: factors (49) Example Call: Expected Return: [7]...

  • 7. Suppose that the equal 1ists function (page 49 of Sebesta) is called with the lists...

    7. Suppose that the equal 1ists function (page 49 of Sebesta) is called with the lists ((A (B)) (C) ) and ((A (B)) (C)) as the arguments. How many calls of equal lists will be performed altogether, including the original call and all recur- sive calls? The following is an example of a Lisp program: Lisp Example function The following code defines a Lisp predicate function that takes two lists as arguments and returns True ;if the two lists are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT