Question: solve this in python dict_contains_keys(items:set, example_dict:dict)->bool This function will have two parameters. The first is a set of numbers known as Number Set. The second

solve this in python

dict_contains_keys(items:set, example_dict:dict)->bool

This function will have two parameters. The first is a set of numbers known as Number Set. The second is a dictionary known as Dictionary. Dictionary will have keys as integers and values as letters. The functions should return true if at least one of the numbers in the Number set is a key in Dictionary. It should return false otherwise.

Example:

Items: {8, 10, 5}

Example: {9: 'F', 10: 'X'}

Expected: True

Items: {8, 9, 5, 1}

Example: {6: 'i', 5: 'Y', 1: 'N', 0: 'E'}

Expected: True

Items: {9, 10, 4}

Example: {5: 'i', 3: 'o', 1: 'N'}

Expected: False

concatenate_dict(dict_list:list)->dict

This function will be given a single parameter known as the Dictionary List. Your job is to combine all the dictionariesfound in the dictionary list into a single dictionary and return it. There are two rules for adding values to thedictionary:

  1. You must add key-value pairs to the dictionary in the same order they are found in the Dictionary List.
  2. If the key already exists, it cannot be overwritten. In other words, if two or more dictionaries have the same key, the key to be added cannot be overwritten by the subsequent dictionaries.

Example:

Dictionary List: [{'Z': 6, 'k': 10, 'w': 3, 'I': 8, 'Y': 5}, {'Y': 1, 'Z': 4}, {'X': 2, 'L': 5}]

Expected: {'Z': 6, 'k': 10, 'w': 3, 'I': 8, 'Y': 5, 'X': 2, 'L': 5}

Dictionary List: [{'z': 0}, {'z': 7}]

Expected: {'z': 0}

Dictionary List: [{'b': 7, 'b': 10, 'A': 8, 'Z': 2, 'V': 1}]

Expected: {'b': 7, 'A': 8, 'Z': 2, 'V': 1}

unique_values(a_dict:dict)-> dict

This function will receive a single dictionary parameter known as a_dict.a_dict will contain a single letter as a string and numbers as values. This function is supposed to search a_dict to find all values that appear only once in the a_dict. The function will make another dictionary named to_ret. For all values that appear once ina_dict the function will add the value as a key in to_retand set the value of the key to the key of the value ina_dict (swap the key-value pairs, since a_dict contains letters to numbers, to_retwill contain Numbers to Letters). Finally, the function should returnto_ret.

Example:

a_dict: {'X': 2, 'Y': 5, 'N': 2, 'L': 2, 'W': 1, 'G': 0, 'R': 1}

Expected: {5: 'Y', 0: 'G'}

a_dict: {'Z': 3, 'P': 3, 'E': 2, 'G': 0, 'T': 5, 'L': 1, 'Q': 0}

to_ret: {2: 'E', 5: 'T', 1: 'L'}

a_dict: {'E': 3, 'X': 3}

to_ret: {}

a_dict: {'G': 3, 'D': 3, 'C': 4, 'Q': 1, 'H': 1, 'M': 2, 'Z': 1, 'W': 3}

to_ret: {4: 'C', 2: 'M'}

a_dict: {'O': 2, 'T': 1, 'L': 5, 'W': 5, 'Z': 4, 'M': 5, 'B': 4, 'D': 0, 'F': 3, 'E': 1}

to_ret: {2: 'O', 0: 'D', 3: 'F'}

dict_from_string(dict_str:str)->dict

This function will be given a single parameter, a string representing a dictionary. Your job is to convert the string into an actual dictionary and return the dictionary. Make sure all key-value pairs in the string exist in the newly created dictionary. The string will contain only numbers or single letters as key values pairs. Make sure all letters are kept as strings and all numbers are converted to integers in the newly created dictionary.

Example:

String Input: '{9: 'V', 'G': 0, 'M': 9, 'u': 3, 2: 'o', 8: 'u', 'q': 9, 'D': 1}'

Expected: {9: 'V', 'G': 0, 'M': 9, 'u': 3, 2: 'o', 8: 'u', 'q': 9, 'D': 1}

String Input: '{10: 'D', 1: 'Z', 5: 'a'}'

Expected: {10: 'D', 1: 'Z', 5: 'a'}

String Input: '{'M': 2, 'V': 0, 3: 'x', 6: 'J', 5: 'J', 7: 'T', 8: 'P', 4: 'q', 1: 'h'}'

Expected: {'M': 2, 'V': 0, 3: 'x', 6: 'J', 5: 'J', 7: 'T', 8: 'P', 4: 'q', 1: 'h'}

String Input: '{3: 'D', 10: 'T', 7: 'm', 'u': 9, 't': 5, 6: 'Z', 'H': 10, 'B': 6}'

Expected: {3: 'D', 10: 'T', 7: 'm', 'u': 9, 't': 5, 6: 'Z', 'H': 10, 'B': 6}

String Input: '{'q': 10, 6: 'O', 'm': 6}'

Expected: {'q': 10, 6: 'O', 'm': 6}

flip_matrix(mat:list)->list

You will be given a single parameter a 2D list (A list with lists within it) this will look like a 2D matrix when printed out, see examples below. Your job is to flip the matrix on its horizontal axis. In other words, flip the matrix horizontally so that the bottom is at top and the top is at the bottom. Return the flipped matrix.

To print the matrix to the console:

 print(' '.join([''.join(['{:4}'.format(item) for item in row]) for row in mat])) 

Example:

Matrix:

WR I T X

H D R L G

L K F M V

G I S T C

W N M N F

Expected:

W N M N F

G I S T C

L K F M V

H D R L G

W R I T X

Matrix:

L C

S P

Expected:

S P

L C

Matrix:

A D J

A Q H

J C I

Expected:

J C I

A Q H

A D J

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!