Changes

Jump to: navigation, search

OPS445 Online Lab4

18 bytes added, 19:44, 1 February 2022
m
PART 3 - Dictionaries
::'''Perform the Following Steps:'''
::#Let's begin by creating a new dictionary in a temporary Python file:<source lang="python">
dict_york = {'Address': '70 The Pond Rd', 'City': 'Toronto', 'Postal Code': 'M3J3M6', 'Province': 'ON'}
</source>You should note that the syntax to define a dictionary is similar to defining sets (i.e. using '''{}'''), but unlike sets dictionaries use '''<code>key:value</code>''' pairs within the dictionary, each ''key:value'' pair is separated by commas.
::#All the values in a dictionary can be retrieved by using the '''dictionary.values()''' function. This particular function provides a '''list''' containing all values:<source lang="python">
572
edits

Navigation menu