Please help me with Function Programming to write this short programming Q1. Wri
ID: 3836432 • Letter: P
Question
Please help me with Function Programming to write this short programming
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.
Assignment Submission Instructions
Submit your work as two files:
A .ml or .caml code file (which must execute without warnings or errors)
A Microsoft Word document containing the contents of your code file (see further instructions below
Name your files as follows: YourFirstName_YourLastName_E4 (.ml or .caml, and .doc or .doctx)
In your code file, put your name, assignment name, and the date the assignment work must be submitted, at the top.
The questions and your explanations/reasoning must be included as comments in your code listing. The comments must:
Respond to any questions asked within the primary questions given above
Explain the functioning of the code segments you have written
Provide your reasoning for why you chose to write the code the way you did and if you considered any alternate ways of writing it
Make sure that the file is easily read i.e. it is nicely formatted with blank lines separating code segments, and comments appropriately associated with the relevant code segments, so that one can easily understand what you have written.
Copy your entire code listing and paste it into a Microsoft Word document. In the Microsoft Word document, change the comments text to green-colored font (your code text should be in black-colored font; this Word document too should be easily readable). See example below:
(* Comments here *)
Code statements here
Explanation / Answer
1):
here which takes two lists and turns them into a dictionary with the first list being the keys and the second being the values. If the keys exceed the values the value "None" will be assigned to that key
2):