MIS 304 Lecture Notes - Lecture 15: Empty Set

47 views2 pages

Document Summary

An object that stores a collection of data. Key-value pairs (mappings): elements stored in dictionaries. Key: must be immutable and unique to dictionary. If key exists in dictionary, the expression returns the value associated with the key. Adding new key-value pairs: dictionary_name[key] = value. If key already exists, the value is changed. If key does not exist, the key and value will be added. If the key does not exist, a keyerror exception is raised. Creating a dictionary: { key" : "value", key" : value", key" : value" } Variable = len(dictionary): gets number of elements in a dictionary. Dictionary. clear(): clears the contents of a dictionary. Dictionary. get(key, default): gets the value associated with a specified key. If the key is not found, the method does not raise an exception. Dictionary. items(): returns all the keys in a dictionary and their associated values as a sequence of tuples. Dictionary. keys(): returns all the keys in a dictionary as a sequence of tuples.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents