Changes

Jump to: navigation, search

OPS435 Python Lab 4

24 bytes added, 08:08, 21 June 2017
PART 3 - Dictionaries
list_of_keys[0]
list_of_values[0]
</source>Now, let's use these '''newly-created lists''', '''len()''' &amp; '''range()''' functions with a '''for loop''' to construct our dictionary:<br><br>
::#Issue the following:<source>
list_of_keys = list(dict_york.keys())
:::::'''create_dictionary()'''<ol><li>'''accepts''' two lists as arguments keys and values, '''combines''' these lists together to '''create''' a dictionary</li><li>'''returns a dictionary''' that has the keys and associated values from the lists</li></ol>
:::::'''split_dictionary()'''<ol><li>'''accepts''' a single dictionary as a argument and '''splits''' the dictionary into two lists, keys and values</li><li>'''returns two lists''': The return function can return multiple lists (separated by a comma). In our case, use: '''return keys, values'''</li></ol>
:::::'''shared_values()''' <ol><li>'''accepts''' two dictionaries as arguments and '''finds''' all values that are shared between the two dictionaries</li><li>'''returns a set''' containing '''ONLY values ''' found in '''BOTH dictionaries'''</li></ol>
:::*make sure the functions have the correct number of arguments required
:::*The script should show the exact output as the samples
13,420
edits

Navigation menu