6. Dictionaries and Sets

Objectives

In this chapter, you’ll:

  • Use dictionaries to represent unordered collections of key–value pairs.
  • Use sets to represent unordered collections of unique values.
  • Create, initialize and refer to elements of dictionaries and sets.
  • Iterate through a dictionary’s keys, values and key–value pairs.
  • Add, remove and update a dictionary’s key–value pairs.

Objectives (cont.)

  • Use dictionary and set comparison operators.
  • Combine sets with set operators and methods.
  • Use operators in and not in to determine if a dictionary contains a key or a set contains a value.
  • Use the mutable set operations to modify a set’s contents.
  • Use comprehensions to create dictionaries and sets quickly and conveniently.
  • Learn how to build dynamic visualizations and implement more of your own in the exercises.
  • Enhance your understanding of mutability and immutability.

Outline (cont.)


©1992–2020 by Pearson Education, Inc. All Rights Reserved. This content is based on Chapter 6 of the book Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and the Cloud.

DISCLAIMER: The authors and publisher of this book have used their best efforts in preparing the book. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in these books. The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs.