CECS 174 Lecture Notes - Lecture 8: Anthony Giacalone, Mike Trout, Yasiel Puig

84 views8 pages

Document Summary

# a "dictionary" is a "data structure" -- a way of organizing many values into. A list is another type of data structure. # typically allow us to add, remove, and find values in them. # of a list are associated with a position (an integer index), values of a. # a python dictionary is denoted with { }, similar to a list denoted with [ ]. # instead of individual values separated by commas, we give a list of. The "key" of each pair is something easy to remember, # through which the dictionary can provide access to the associated value. # to retrieve a value, we "index" the dictionary with the associated key. print("neal"s phone number is " + contacts["neal terrell"]) print("mehrdad"s phone number is " + contacts["mehrdad aliasgari"]) # keys have to match exactly; it is a run-time error (semantic error) to index. # a dictionary with a key that does not exist.

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