Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. Write a function to build a dictionary from two lists of equal length. One of the lists should contain elements that will serves as

Q1. Write a function to build a dictionary from two lists of equal length. One of the lists should contain elements that will serves as keys and the other list should contain elements that will serve as values.

Run your code to demonstrate that it works. Include the output in your answer. The output should show the two starting lists and the resulting dictionary.

What happens if the lists should chance to be of unequal length?

Q2. Now write a function that will do the inverse of the operation above i.e. this function takes a dictionary and returns two lists, one list containing keys and the other list containing values.

Can you really return two independent lists (i.e. can a function return two values)? How will you resolve this problem?

Run your code to demonstrate that it works. Include the output in your answer. The output should show the starting dictionary and the two resulting lists.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago